feat: renderSync, parseAndRenderSync and renderFileSync, see #48

This commit is contained in:
harttle
2019-08-26 10:15:43 -05:00
committed by Jun Yang
parent 8028f82499
commit 7fb01ad69a
66 changed files with 896 additions and 272 deletions
+3 -3
View File
@@ -10,9 +10,9 @@ engine.registerTag('header', {
const [key, val] = token.args.split(':')
this[key] = val
},
render: function (scope, hash) {
const title = this.liquid.evalValue(this.content, scope)
return `<h1>${title}</h1>`
render: async function (scope, hash, emitter) {
const title = await this.liquid.evalValue(this.content, scope)
emitter.write(`<h1>${title}</h1>`)
}
})
+4 -4
View File
@@ -1,4 +1,4 @@
import { Liquid, TagToken, Hash, Context } from 'liquidjs'
import { Liquid, TagToken, Hash, Context, Emitter } from 'liquidjs'
const engine = new Liquid({
root: __dirname,
@@ -10,9 +10,9 @@ engine.registerTag('header', {
const [key, val] = token.args.split(':')
this[key] = val
},
render: function (context: Context, hash: Hash) {
const title = this.liquid.evalValue(this['content'], context)
return `<h1>${title}</h1>`
render: async function (context: Context, hash: Hash, emitter: Emitter) {
const title = await this.liquid.evalValue(this['content'], context)
emitter.write(`<h1>${title}</h1>`)
}
})