An open API service indexing awesome lists of open source software.

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.

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