https://github.com/devtheorem/php-handlebars-parser
Parse Handlebars templates to a spec-compliant AST with PHP.
https://github.com/devtheorem/php-handlebars-parser
handlebars parser php
Last synced: 8 months ago
JSON representation
Parse Handlebars templates to a spec-compliant AST with PHP.
- Host: GitHub
- URL: https://github.com/devtheorem/php-handlebars-parser
- Owner: devtheorem
- License: mit
- Created: 2024-12-25T16:04:59.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-05-18T14:50:40.000Z (8 months ago)
- Last Synced: 2025-05-24T22:48:43.639Z (8 months ago)
- Topics: handlebars, parser, php
- Language: PHP
- Homepage:
- Size: 103 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Handlebars Parser
Parse [Handlebars](https://handlebarsjs.com) templates to a spec-compliant AST with PHP.
## Installation
`composer require devtheorem/php-handlebars-parser`
## Usage
```php
use DevTheorem\HandlebarsParser\ParserFactory;
$parser = (new ParserFactory())->create();
$template = "Hello {{name}}!";
$result = $parser->parse($template);
```
If the template contains invalid syntax, an exception will be thrown.
Otherwise, `$result` will contain a `DevTheorem\HandlebarsParser\Ast\Program` instance.
## Author
Theodore Brown