Skip to content

Commit aef3c65

Browse files
committed
Expand readme and grammar notes
1 parent 0adc64b commit aef3c65

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
Parse [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);
2124
If the template contains invalid syntax, an exception will be thrown.
2225
Otherwise, `$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

grammar/handlebars.y

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@
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

4546
program:

0 commit comments

Comments
 (0)