We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0b9b50c commit 9504e4eCopy full SHA for 9504e4e
bin/liquid.js
@@ -1,13 +1,24 @@
1
#!/usr/bin/env node
2
3
const Liquid = require('..').Liquid
4
+var contextArg = process.argv.slice(2)[0]
5
+var context = {}
6
+
7
+if (contextArg) {
8
+ if (contextArg.endsWith('.json')) {
9
+ const fs = require('fs')
10
+ context = JSON.parse(fs.readFileSync(contextArg, 'utf8'))
11
+ } else {
12
+ context = JSON.parse(contextArg)
13
+ }
14
+}
15
16
let tpl = ''
17
process.stdin.on('data', chunk => (tpl += chunk))
18
process.stdin.on('end', () => render(tpl))
19
20
async function render (tpl) {
21
const liquid = new Liquid()
- const html = await liquid.parseAndRender(tpl)
22
+ const html = await liquid.parseAndRender(tpl, context)
23
console.log(html)
-}
24
0 commit comments