Skip to content

Commit

Permalink
feat: CLI support
Browse files Browse the repository at this point in the history
echo '{{ "hello" | capitalize }}' | liquidjs
  • Loading branch information
harttle committed Aug 1, 2019
1 parent c8c6dd8 commit fc045b5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ engine
.then(console.log) // outputs "Alice"
```

Or from the CLI:

```bash
echo '{{ "hello" | capitalize }}' | liquidjs
```

## Use with Express.js

```javascript
Expand Down
21 changes: 21 additions & 0 deletions bin/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
13 changes: 13 additions & 0 deletions bin/liquid.js
Original file line number Diff line number Diff line change
@@ -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)
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit fc045b5

Please sign in to comment.