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

Partials remove leading whitespace in partial #182

Open
apatrida opened this issue Apr 16, 2019 · 4 comments
Open

Partials remove leading whitespace in partial #182

apatrida opened this issue Apr 16, 2019 · 4 comments

Comments

@apatrida
Copy link

apatrida commented Apr 16, 2019

When including a partial that has important indentation, for example:

<pre>
   fun something() {
       var x = 1;
   }
</pre>

This is imported as a partial as:

<pre>
fun something() {
var x = 1;
}
</pre>

Which breaks the intention.

@apatrida
Copy link
Author

(it appears it is setting the indentation of all lines to match the indentation of the partial import, if this {{> thingy}} has 3 leading spaces, is it indenting the imported to match 3 leading spaces and destroying other indentation?`

@apatrida
Copy link
Author

Handlebars has a setting preventIndent http://handlebarsjs.com/reference.html is that affecting this? But overall it isn't just indenting the content it is removing my own indentation and then indenting it. Which is evil.

@elcaptain
Copy link

elcaptain commented Mar 26, 2020

I'm having the same problem. I am using foundation-emails and since the whole body of the emails gets imported by a partial it messes up the indentation of my <pre> tags.
My quick fix was to add {preventIndent: true} to the compile command in panini/lib/loadLayout.js like this: this.layouts[name] = this.Handlebars.compile(file.toString(), {preventIndent: true});

@elcaptain
Copy link

Apparently there was already a PR to allow the preventIndet option: #113
It even got merged into the 2.0 branch. Which hasn't been released in the last 2 years :/

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

No branches or pull requests

2 participants