docs: fix demos

This commit is contained in:
harttle
2020-03-10 01:08:25 +08:00
parent 2c428221cb
commit 06ad0481db
3 changed files with 30 additions and 27 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ engine.registerTag('header', {
const [key, val] = token.args.split(':')
this[key] = val
},
render: async function (scope, hash, emitter) {
render: async function (scope, emitter) {
const title = await this.liquid.evalValue(this.content, scope)
emitter.write(`<h1>${title}</h1>`)
}
+4 -1
View File
@@ -21,5 +21,8 @@
"not dead",
"not ie <= 11",
"not op_mini all"
]
],
"devDependencies": {
"@babel/core": "^7.8.7"
}
}
+25 -25
View File
@@ -1,25 +1,25 @@
import { Liquid, TagToken, Hash, Context, Emitter } from 'liquidjs'
const engine = new Liquid({
root: __dirname,
extname: '.liquid'
})
engine.registerTag('header', {
parse: function (token: TagToken) {
const [key, val] = token.args.split(':')
this[key] = val
},
render: async function (context: Context, hash: Hash, emitter: Emitter) {
const title = await this.liquid.evalValue(this['content'], context)
emitter.write(`<h1>${title}</h1>`)
}
})
const ctx = {
todos: ['fork and clone', 'make it better', 'make a pull request'],
title: 'Welcome to liquidjs!'
}
// console.log('isTruthy:', isTruthy('a string here'));
engine.renderFile('todolist', ctx).then(console.log)
import { Liquid, TagToken, Context, Emitter } from 'liquidjs'
const engine = new Liquid({
root: __dirname,
extname: '.liquid'
})
engine.registerTag('header', {
parse: function (token: TagToken) {
const [key, val] = token.args.split(':')
this[key] = val
},
render: async function (context: Context, emitter: Emitter) {
const title = await this.liquid.evalValue(this['content'], context)
emitter.write(`<h1>${title}</h1>`)
}
})
const ctx = {
todos: ['fork and clone', 'make it better', 'make a pull request'],
title: 'Welcome to liquidjs!'
}
// console.log('isTruthy:', isTruthy('a string here'));
engine.renderFile('todolist', ctx).then(console.log)