mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 12:20:40 -07:00
feat: CLI support
echo '{{ "hello" | capitalize }}' | liquidjs
This commit is contained in:
@@ -98,6 +98,12 @@ engine
|
||||
.then(console.log) // outputs "Alice"
|
||||
```
|
||||
|
||||
Or from the CLI:
|
||||
|
||||
```bash
|
||||
echo '{{ "hello" | capitalize }}' | liquidjs
|
||||
```
|
||||
|
||||
## Use with Express.js
|
||||
|
||||
```javascript
|
||||
|
||||
@@ -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
@@ -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)
|
||||
}
|
||||
@@ -17,6 +17,10 @@
|
||||
"build": "rollup -c rollup.config.ts && ls -lh dist",
|
||||
"version": "npm run build"
|
||||
},
|
||||
"bin": {
|
||||
"liquidjs": "./bin/liquid.js",
|
||||
"liquid": "./bin/liquid.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/harttle/liquidjs.git"
|
||||
|
||||
Reference in New Issue
Block a user