Call Spacebars Template from Javascript?

I have searched for this around the net, and not really finding what I’m looking for, but is there a way to call / display a Spacebars Template from javascript?

E.g. from the leaflet map, I put an icon on it in javascript, and from that marker is a tooltip object you can add, and you can use html in that object, but I would like to create a template for the tooltip / popup.

.bind(tooltip('<p> this is my info</p><br />and this is a 2nd line ' + someData + ' more stuff, and so on.')); 

but I would rather do

.bind(tooltip('{{> myToolTipTemplate}}');

Will that work? or is there a prescribed way to do this?

As always any help and guidance is appreciated.

you need a string there, so you can use Blaze.toHTMLWithData: http://blazejs.org/api/blaze.html#Blaze-toHTMLWithData

2 Likes