Closed eden-lane closed 11 years ago
var Handlebars = require('handlebars');
Thanks. I thought so.
We use this approach all the time for our helpers: https://github.com/yui/pure-site/blob/master/lib/helpers.js
I see. I thought that I shouldn't require handlebars for optimization reasons, because express3-handlebars already includes it. Sorry for my misunderstood, I'm still new in node.js
You can always use the reference from your Express Handlebars instance, whichever is easiest for you, the perf difference won't matter if you're doing the require()
once, at top of a module.
Okay, thank you for the detailed answer and for your time !
Seems that even if I use new Handlebars().SafeString it is still escaped. Did this work for you @edencore ?
Seems that there is an issue here. SafeString only works if I use my helper as:
{{#marker x y z}}{{/marker}} and does not work if I use {{marker x y z}}
Should I raise this as an Issue?
@aiten it works well for me. Here is the example: http://jsbin.com/EpixuCA/2/edit (if I understand you correct). But I guess this question is for Handlebars repository, not for this one.
I might be late to the party here, but you can prevent handlebars from escaping the output by using the triple-stash, e.g. {{{marker x y z}}}
If this works it is a winner.
On 12 February 2014 10:05, habhab notifications@github.com wrote:
I might be late to the party here, but you can prevent handlebars from escaping the output by using the triple-stash, e.g. {{{marker x y z}}}
— Reply to this email directly or view it on GitHubhttps://github.com/ericf/express3-handlebars/issues/34#issuecomment-34854544 .
ꜽ . antony jones . http://www.enzy.org
Ditto on issue where Handlebars.SafeString only works with block helpers.
Handlebars uses an instanceof
check to determine whether a string is a SafeString
. There can be a problem with this if you have multiple copies of Handlebars in your app, i.e. express-handlebars
is using a different version or copy than what's in your app's package.json
.
To mitigate this, simply have express-handlebars
use the same Handlebars
instance you have in your apps — which is used in your custom helpers — by passing a reference to your copy Handlebars
when you configure Express Handlebars.
How can I use
new Handlebars.SafeString()
?