HTML::Template-like templating language parser, that can parse a pragmatic subset of HTML/TMPL tag combinations (see #1) and Perl expressions.
npm install htmltemplate-parser
$ htmltemplate-parser --help
Usage: htmltemplate-parser [options]
Options:
--path file to parse [string] [required]
--pretty output with colors [boolean]
--ignore-html treat HTML tags as text [boolean]
Parse the supplied template string and return the corresponding AST. Available options:
ignoreHTMLTags
, (defaultfalse
) โ do not attempt to parse HTML tags, treat them as text,reducePositionLookups
, (defaultfalse
) โ do not calculate line, column and offset for most nodes, this would speedup parsing of large files.
var fs = require('fs');
var inspect = require('util').inspect;
var parser = require('htmltemplate-parser');
var tmpl = fs.readFileSync('./example.inc', 'utf8');
var ast = parser.parse(tmpl);
console.log(inspect(ast, { colors: true, depth: Infinity }));