When I use the Mustache Template to loop through an object to produce a list there is an extra line added between items. Is there a way to suppress this? Example code below:
let t = `# Template Test
{{#list_test}}
- {{item}}
{{/list_test}}`;
let item1 = {
item: '1'
}
let item2 = {
item: '2'
}
let templ_data = {
"list_test" : [item1,item2]
}
let template = MustacheTemplate.createWithTemplate(t);
let result = template.render(templ_data);
console.log(result);
// Output is:
// # Template Test
//
// - 1
//
// - 2
//
shoot, that works in the sample, but I’m actually using the contents of another Draft for my template layout and using the \n there doesn’t work. Got to get back to my real job though
Modified my example, the template should just end with a line feed. If you are using `` (back-tick) template strings in JavaScript, you do not escape line feeds as \n like you would in double or single quoted strings.