0.2.2 • Published 12 months ago
twig-parser v0.2.2
Twig Parser
This tool transforms a twig template to AST. It uses chevrotain under the hood.
How to use it
import { parse } from 'twig-parser';
const twig = `
{% set foo = range(0, 3) %}
{% for i in foo %}
{{ i }},
{% endfor %}
`
const { ast, tokens, errors } = parse(twig);
Notes
- Whitespace trimming is not supported
- The body of the verbatim tag is parsed as a regular template