Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partial compiler option for preventIndent #95

Closed
ericlowry opened this issue Dec 5, 2014 · 5 comments
Closed

partial compiler option for preventIndent #95

ericlowry opened this issue Dec 5, 2014 · 5 comments

Comments

@ericlowry
Copy link

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

 or <textarea> tags where whitespace matters.

I need a way to specify that I want to set the compiler options to include the 'preventIndent = true' flag when loading partials...

Thanks!

@ericf
Copy link
Owner

ericf commented Dec 5, 2014

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.

@ericf
Copy link
Owner

ericf commented Feb 12, 2015

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.

@ericf
Copy link
Owner

ericf commented Mar 22, 2015

Closing this since #105 was merged.

@ericf ericf closed this as completed Mar 22, 2015
@jme783
Copy link

jme783 commented Apr 1, 2015

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!

@jme783
Copy link

jme783 commented Apr 1, 2015

Solved! I just had to make sure I was updated to the newest version of express-handlebars, 2.0.0 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants