Closed Radiergummi closed 7 years ago
Still not fixed @psychobunny..
I'm running the newest template.js-version, but when trying to add an if-statement to the category-template in NodeBB, it messes up the html
`
<h2 component="topic/header" class="title">
<i component="topic/pinned" class="fa fa-thumb-tack hide" title="Pinned"></i>
<i component="topic/locked" class="fa fa-lock hide" title="Locked"></i>
<i component="topic/moved" class="fa fa-arrow-circle-right hide" title="Moved"></i>
<!-- IF !topics.noAnchor -->
<a href="/topic/3/asdasdasd" itemprop="url">Asdasdasd</a><br>
</h2></div>`
hmm.. Have abandoned templates.js in favor of handlebars now, which is sad actually. I find the syntax with handlebars way worse.
Fixed in Benchpress
When creating rather complex templates, eg. nested loops and several IF statements, at some point templates.js messes up. Some comments stay in the output, data is not necessarily parsed as intended at all.
I managed to put a test case together, see below:
Template:
Options:
Expected output:
Actual output (
templates.parse(test, options)
):Now, once running this without any options (
templates.parse(test, {})
):First condition false (
templates.parse(test, { firstCondition: false })
):First condition true, second false, firstLoop present but empty (
templates.parse(test, { firstCondition: true, secondCondition: false, firstLoop: [] })
):