@rhinostone/swig-twig
v2.7.3
Published
Twig-syntax frontend for the @rhinostone/swig-core template engine. Part of the @rhinostone/swig multi-flavor family.
Maintainers
Readme
@rhinostone/swig-twig
Twig-syntax frontend for the @rhinostone/swig-core template engine. Part of the multi-flavor architecture introduced in 2.0.0 — see ROADMAP.md for the release narrative.
Installation
npm install @rhinostone/swig-twigThis pulls in @rhinostone/swig-core as a peer dependency, pinned to the matching version. Frontends and the core release in lockstep — do not mix versions.
Basic example
var swig = require('@rhinostone/swig-twig');
var out = swig.render('Hello, {{ name|upper }}!', {
locals: { name: 'world' }
});
// => Hello, WORLD!Supported surface (as of 2.0.0)
- Tags —
apply,block,extends,for,from,if,import,include,macro,set,verbatim,with. - Operators —
..range,??null-coalescing,~string concat,is <test>/is not <test>. - Built-in
istests —defined,null,empty,iterable,odd,even,divisibleby. - Filters — the Twig core overlaps (length, lower, upper, first, last, join, reverse, sort, striptags, url_encode, json_encode, raw, escape / e, slice, split, batch, trim, number_format, replace, keys, format, merge, date). See
lib/filters.jsfor the full list.
Explicitly unsupported (parse-time throw)
{% sandbox %}— security-sandbox tag, out of scope.- Macro kwargs — use positional args.
{% use %}— not implemented.{% deprecated %}— not implemented; use comment pragmas.
Repository
Source: gina-io/swig/packages/swig-twig. File issues and PRs at gina-io/swig.
License
MIT. See LICENSE in the monorepo root.
