javascript - MustacheJS partials not rendering -


i trying use partial simple object enumerable property, partials won't render.

here link sample.

the object

obj6    = {            people : [               { firstname : 'jayson', lastname : 'buquia', ismale : true },               { firstname : 'jane', lastname : 'doe', ismale : false },               { firstname : 'john', lastname : 'smith', ismale : true }             ]           }; 

the partials

 partials = { person : '<li>{{ firstname }} {{ lastname }}{{^ismale}}, female {{/ismale}}.</li>' } 

the template

<ul>   {{ #people }}      {{>person}}   {{ /people }} </ul> 

try change tpl = $('.template .main').html() tpl = $('.template .main').text() html() wll return <h3>names:</h3><ul>{{ #people }} {{&gt;person}}{{ /people }}</ul> not valid template.

var $p     = $('#container'), tpl     = $('.template .main').text(),            partials = { person : '<li>{{ firstname }} {{ lastname }}{{^ismale}}, female {{/ismale}}.</li>' },         obj6    = {             people : [                 { firstname : 'jayson', lastname : 'buquia', ismale : true },                 { firstname : 'jane', lastname : 'doe', ismale : false },                 { firstname : 'john', lastname : 'smith', ismale : true }             ]         };   $p.append(mustache.render(tpl,obj6,partials)); 

demo

or convert div script tag templete here demo:-

demo


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -