Closed ericlowry closed 9 years ago
Okay, interesting…
You can hack this in by overriding the compileTemplate()
method:
https://github.com/ericf/express-handlebars/blob/master/lib/express-handlebars.js#L58-65
If you're up for it, it would be great if you created a PR to add a feature to support passing compile-time options. I never had a need for it, which is why I didn't even realize they exist. I think it might make sense to set the compilerOptions
during instance creation of ExpressHandlebars
, since this doesn't seem like a think you'd want to specify during render time.
In #105 I've added a new config property: compilerOptions
, plus I've replaced the compileTemplate()
hook with _compileTemplate()
and _precompileTemplate()
both of which are passed the compilerOptions
. Let me know if this new options satisfies what you are after here.
Closing this since #105 was merged.
Hi there, I'm running into this and would like to use the new compilerOptions
config property with preventIndent
. After trying to implement, I'm still noticing an indent in my preformatted code. Does this look correct?
app.engine('.hbs', exphbs({
defaultLayout: 'main',
extname: '.hbs',
partialsDir: 'views/partials/',
compilerOptions: {
preventIndent: true
}
}));
app.set('view engine', '.hbs');
Any help would be greatly appreciated! Thanks!
Solved! I just had to make sure I was updated to the newest version of express-handlebars
, 2.0.0 :+1:
With Handlebars 2.0, partials get indented automatically in the resulting document. This is great most of the time, unless you are generating content with