ahsan_cse2004
ahsan_cse2004

Reputation: 160

Access Mustache object inside ICanHaz object

I am using icanhaz inside my project. As per documentation it says that it includes the Mustache.js as well.

Now I want to access the embedded Mustache object's to_html() method as follows.

var message = Mustache.to_html(template, json, true);

I am however getting error 'Mustache not defined'. Since Mustache is already included inside iCanHaz.js and I am successfully using ICanHaz's other methods as well, I should not need to include entire Mustache library again just for calling this single method, Or should I?

I just want my template to render as normal string with values replaced from my json object. Any other simple and lightweight way is also appreciated.

Thanks

Upvotes: 3

Views: 203

Answers (1)

Hakan B.
Hakan B.

Reputation: 2379

No need to directly use the Mustache object.

Pass true to your normal ICanHaz render method to get the HTML string:

var message = ich.myTemplate(json, true);

Upvotes: 2

Related Questions