janl / mustache.js

Minimal templating with {{mustaches}} in JavaScript

Home Page:https://mustache.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Client side rendering of parameter for Mustache is overridden by that of handlebar

s-mrb opened this issue · comments

commented

I am using Mustache and Handlebars simultaneously for views and templates. The problem doing so is that if I use {{parameter}} in .hbs file then how do i make sure that this parameter is rendered with Mustache in client side JS and not via res.render in server side.

The default behaviour is that the hbs file assumes that this {{parameter}} is sent from server side handlebars rendereing and if i actually sent this from Mustache and not server side handlebars then it appears null.

Thanks.

Since handlebars is a superset/extension of the mustache syntax, this would be expected and for many, a big benefit as it allows the same templates to be rendered on the server & client.

If you want to avoid that from happening, the option I'd consider would be changing the delimiters on either the mustache or handlebars side. How that's done for mustache.js in particular can be seen in our README.md / Custom delimiters section.

If that doesn't work out for you, I'd suggest you ask for more creative advice on StackOverflow or similar, since this isn't an issue with mustache.js.