High-performance Liquid template engine powered by Zig
npm install liquidzHigh-performance Liquid template engine for Node.js, Bun, and Deno, powered by Zig.
``bash`
npm install liquidz
Prerequisites: You need to build the Zig library first:
`bash`
cd ../.. # Go to project root
zig build -Doptimize=ReleaseFast
`javascript
const { render } = require('liquidz');
// Simple variable substitution
const result = render('Hello, {{ name }}!', { name: 'World' });
console.log(result); // "Hello, World!"
// With loops
const list = render('{% for item in items %}{{ item }} {% endfor %}', {
items: ['a', 'b', 'c']
});
console.log(list); // "a b c "
// With conditionals
const conditional = render('{% if show %}visible{% endif %}', { show: true });
console.log(conditional); // "visible"
// With filters
const filtered = render('{{ name | upcase }}', { name: 'hello' });
console.log(filtered); // "HELLO"
// Using JSON string directly
const fromJson = render('{{ x }}', '{"x": 42}');
console.log(fromJson); // "42"
`
Renders a Liquid template with the given data.
- template (string): The Liquid template stringdata
- (object | string, optional): The data to render with. Can be a JavaScript object or a JSON string. Defaults to {}.
Returns the rendered template as a string.
Throws an error if rendering fails.
Alias for render().
This binding works with multiple JavaScript runtimes:
`bash`
bun run test.js
`bash`
deno run --allow-ffi --allow-read test.js
Note: Deno requires the --allow-ffi` flag for native modules.
MIT