feat: CLI support

echo '{{ "hello" | capitalize }}' | liquidjs
This commit is contained in:
harttle
2019-08-01 13:15:55 +08:00
parent c8c6dd8275
commit fc045b5bbc
4 changed files with 44 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
{
"extends": ["standard"],
"env": {
"mocha": true,
"es6": true,
"browser": true,
"node": true
},
"plugins": [
"mocha",
"standard",
"promise"
],
"rules": {
"no-var": 2,
"prefer-const": 2,
"@typescript-eslint/no-var-requires": "off",
"no-unused-vars": "off",
"indent": "off"
}
}
Executable
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env node
const Liquid = require('..')
let tpl = ''
process.stdin.on('data', chunk => (tpl += chunk))
process.stdin.on('end', () => render(tpl))
async function render (tpl) {
const liquid = new Liquid()
const html = await liquid.parseAndRender(tpl)
console.log(html)
}