Parse Handlebars and HTML.
Parse this:
into this:
[
{ type:"htmlTagStart" },
{ type:"htmlTagNameStart" },
{ type:"hbsTagStart" },
{ type:"hbsExpressionStart" },
{ type:"hbsExpressionPath", value:["tag"] },
{ type:"hbsExpressionEnd" },
{ type:"hbsTagEnd" },
{ type:"htmlTagNameEnd" },
{ type:"htmlTagEnd" },
{ type:"text", text:" value " },
{ type:"hbsTagStart", notEscaped:true },
{ type:"hbsExpressionStart" },
{ type:"hbsExpressionPath", value:["obj","value"] },
{ type:"hbsExpressionEnd" },
{ type:"hbsTagEnd", stripWhitespace:true, notEscaped:true },
// whitespace stripped
{ type:"htmlTagStart", closing:true },
{ type:"htmlTagNameStart" },
{ type:"text", text:"tag" },
{ type:"htmlTagNameEnd" },
{ type:"htmlTagEnd" }
]
β¦for use in compiling to something like a virtual DOM, such that of handlebars-react.
For more information on the strengths, weaknesses and implementation details of this library, check out the wiki.
Type: Boolean
Default value: false
When true
, Handlebars comments will be excluded from output.
Type: Boolean
Default value: false
When true
, HTML comments will be excluded from output.
Type: Boolean
Default value: false
When true
, will replace standard whitespace (line breaks, tabs, regular spaces) with a single space. This helps lower compiled template file size and improve runtime performance.
- Does not affect "special" whitespace chars such as
, etc. - Does not affect text within
<pre>
,<script>
,<style>
tags - Does not affect HTML's rendered appearance
-
How is this different from HTMLBars?
HTMLBars builds a DOM whereas this library allows you to build a DOM and especially a virtual DOM. -
Why not use parse5?
As of v1.5.0, it is not at all "forgiving", in that it will parse<{{tag}}>asdf</{{tag}}>
as text instead of HTML.
- add support for sub-expressions
- add support for
{{#if}}
,{{else}}
,{{else if}}
,{{#unless}}
- add support for
{{#with}}
,{{#each}}
,{{@index}}
,{{@key}}
,{{this}}
,{{.}}
,{{undefined}}
,{{null}}
,{{true}}
,{{1}}
- add support for
{{> partial}}
options.mustacheOnly
that disables helpers, expressions and whitespace control? would have to provide parse errors
- 0.0.1β0.0.9 pre-releases