mustache / spec

The Mustache spec.
MIT License
364 stars 71 forks source link

Partials and Trailing Newlines #61

Closed pvande closed 10 months ago

pvande commented 11 years ago

Example:

{{! template.mustache }}
{{> partial }}
>> {{> partial }}
[ {{> partial }} ]

---
{{> special }}
>> {{> special }}
[ {{> special }} ]
{{! partial.mustache }}
{{! File ends with newline (common standard) }}
{{#things}}{{.}}, {{/things}}
{{! special.mustache }}
{{! File DOES NOT end with newline }}
{{#things}}{{.}}, {{/things}}

Currently specified output:

a, b, c, d, e, 
>> a, b, c, d, e, 

[ a, b, c, d, e, 
 ]

---
a, b, c, d, e, >> a, b, c, d, e, 
[ a, b, c, d, e,  ]

Proposed change:

Standalone partial tags should always interpolate a trailing newline. Non-standalone partial tags should always chomp one trailing newline character before rendering.

Resulting output:

a, b, c, d, e, 
>> a, b, c, d, e, 
[ a, b, c, d, e,  ]

---
a, b, c, d, e, 
>> a, b, c, d, e, 
[ a, b, c, d, e,  ]