janl / mustache.js

Minimal templating with {{mustaches}} in JavaScript

Home Page:https://mustache.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Partials used with object of partials removes space

ToddJ101 opened this issue · comments

Issue description:
Between the versions 3.0.1 and 3.0.2-4.2.0 a change was introduced that affects templates that only have spaces and an object of partials. Previous template output respected the space in the template string, behavior of v3.0.2, and after removes the space in the template string between replaced object partials.

Expected Behavior
When I use the third parameter of .render(template, {}, partials) sending in an object of partials. The template with only spaces between the partials should keep my template string spaces between partial nodes.

Code Example:
const template = '{{> Container1}} {{> Container2}} {{> Container3}}'

// The partial I am using
const partials = {
Container1: 'Container1',
Container2: 'Container2',
Container3: 'Container3'
}

// THE MUSTACHE CALL
const newValues = mustache.render(template, {}, partials)

// 3.0.1 OUTPUT of newValues:
console.log(newValues) // Container1 Container2 Container3

// 3.0.2-4.2.0 OUTPUT of newValues:
console.log(newValues) // Container1Container2Container3