fix: restore --template CLI option

Revert the positional-only template change. Keep --template as the primary API; stdin template remains unsupported without a special error.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Yang Jun
2026-07-26 14:16:00 +08:00
co-authored by Cursor
parent 456d7dc6a4
commit ed801e1581
3 changed files with 10 additions and 10 deletions
+7 -7
View File
@@ -56,33 +56,33 @@ Pre-built UMD bundles are also available:
LiquidJS can also be used to render a template directly from CLI using `npx`:
```bash
npx liquidjs '{{"hello" | capitalize}}'
npx liquidjs --template '{{"hello" | capitalize}}'
```
You can either pass the template inline (as shown above) or you can read it from a file by using the `@` character followed by a path, like so:
```bash
npx liquidjs @./some-template.liquid
npx liquidjs --template @./some-template.liquid
```
A context can be passed inline, from a path, or piped through `stdin`. The following three are equivalent:
```bash
npx liquidjs 'Hello, {{ name }}!' --context '{"name": "Snake"}'
npx liquidjs 'Hello, {{ name }}!' --context @./some-context.json
echo '{"name": "Snake"}' | npx liquidjs 'Hello, {{ name }}!' --context @-
npx liquidjs --template 'Hello, {{ name }}!' --context '{"name": "Snake"}'
npx liquidjs --template 'Hello, {{ name }}!' --context @./some-context.json
echo '{"name": "Snake"}' | npx liquidjs --template 'Hello, {{ name }}!' --context @-
```
The rendered output is written to `stdout` by default, but you can also specify an output file (if the file exists, it will be overwritten):
```bash
npx liquidjs '{{"hello" | capitalize}}' --output ./hello.txt
npx liquidjs --template '{{"hello" | capitalize}}' --output ./hello.txt
```
You can also pass a number of options to customize template rendering behavior. For example, the `--js-truthy` option can be used to enable JavaScript truthiness:
```bash
npx liquidjs @./some-template.liquid --js-truthy
npx liquidjs --template @./some-template.liquid --js-truthy
```
Most of the [options available through the JavaScript API][options] are also available from the CLI. For help on available options, use `npx liquidjs --help`.