foundation / panini

A super simple flat file generator.
Other
592 stars 104 forks source link

Partials remove leading whitespace in partial #182

Open apatrida opened 5 years ago

apatrida commented 5 years ago

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 commented 5 years ago

(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 commented 5 years ago

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 commented 4 years ago

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 commented 4 years ago

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 :/