fix: escape mustache template chars in content

This commit is contained in:
NGPixel
2020-05-08 17:00:02 -04:00
parent 2ff0e42c1d
commit 98bf0d9ccb
5 changed files with 207 additions and 54 deletions

View File

@@ -230,12 +230,31 @@ module.exports = {
headers.push(headerSlug)
})
let output = decodeEscape($.html('body').replace('<body>', '').replace('</body>', ''))
// --------------------------------
// Escape mustache expresions
// --------------------------------
function iterateMustacheNode (node) {
const list = $(node).contents().toArray()
list.forEach(item => {
if (item.type === 'text') {
const rawText = $(item).text()
if (rawText.indexOf('{{') >= 0 && rawText.indexOf('}}') > 1) {
$(item).parent().attr('v-pre', true)
}
} else {
iterateMustacheNode(item)
}
})
}
iterateMustacheNode($.root())
// --------------------------------
// STEP: POST
// --------------------------------
let output = decodeEscape($.html('body').replace('<body>', '').replace('</body>', ''))
for (let child of _.sortBy(_.filter(this.children, ['step', 'post']), ['order'])) {
const renderer = require(`../${_.kebabCase(child.key)}/renderer.js`)
output = await renderer.init(output, child.config)