File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33Parse [ Handlebars] ( https://handlebarsjs.com ) templates to a spec-compliant AST with PHP.
44
5+ Implements the same lexical analysis and grammar specification as Handlebars.js, so any template
6+ which can (or cannot) be parsed by Handlebars.js should parse (or error) the same way here.
7+
58## Installation
69
710` composer require devtheorem/php-handlebars-parser `
@@ -21,6 +24,16 @@ $result = $parser->parse($template);
2124If the template contains invalid syntax, an exception will be thrown.
2225Otherwise, ` $result ` will contain a ` DevTheorem\HandlebarsParser\Ast\Program ` instance.
2326
27+ ## Whitespace handling
28+
29+ The parser can be created with an optional boolean argument,
30+ to support the ` ignoreStandalone ` Handlebars compilation option:
31+
32+ ``` php
33+ $parser = (new ParserFactory())->create(ignoreStandalone: true);
34+ ```
35+
2436## Author
2537
26- Theodore Brown
38+ Theodore Brown
39+ https://theodorejb.me
Original file line number Diff line number Diff line change 3737%%
3838
3939/*
40- * Should match the grammar (as of 2025-01-20) of
41- * https://github.com/handlebars-lang/handlebars-parser/blob/master/src/handlebars.yy
42- * EBNF grammar has been converted to BNF.
40+ * Grammar should match https://github.com/handlebars-lang/handlebars-parser/blob/master/src/handlebars.yy
41+ * as of 2026-02-20. EBNF grammar has been converted to BNF.
42+ * Exception: the hash and array literal syntax (https://github.com/handlebars-lang/handlebars-parser/pull/15)
43+ * has been reverted for parity with the released version of Handlebars.js.
4344 */
4445
4546program :
You can’t perform that action at this time.
0 commit comments