Trying to dynamically create html page with spacebars inside


#1

Hey there,

I am trying to generate html with spacebars inside that and i am getting this :slight_smile:

This is my way of adding html :

I just want that {{state โ€˜x.yโ€™}} to be rendered as handlebars not text.

Any idea would be great. Thanks for your time.


#2

Spacebars / handlebars html needs to be compiled. Itโ€™s not dynamic. You need to have your html already including all the spacebars instructions in it. Please look at the guide as you donโ€™t need to dynamically alter the DOM (HTML). Look for leveluptuts on youtube and follow his Meteor tutorials.


#3

Can u be more specific ? Maybe some example, based on my code ?


#4

Ok, here it is again. Create your template HTML in advance. Not with JS.
So your HTML that you shared as an image, is fine. Generate it like this:
``
{{#each item in items}}

{{state item}}
{{/each}} `` We typically use JS for events in this case, not for DOM manipulation.

#5

I was just wondering way around that. Making it from js like in react. Thanks anyway, that was helpful.