Skip to content

Commit 684ed07

Browse files
committed
Implement Handlebars tokenizer
This should produce the exact same tokens for any template as the Handlebars JS implementation.
0 parents  commit 684ed07

File tree

12 files changed

+2289
-0
lines changed

12 files changed

+2289
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.github/ export-ignore
2+
/test/ export-ignore

.github/workflows/php.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: PHP Composer
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
name: Run tests on ${{ matrix.php }}
6+
runs-on: ubuntu-latest
7+
8+
strategy:
9+
matrix:
10+
php: [ '8.2', '8.3', '8.4' ]
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
# Docs: https://github.com/shivammathur/setup-php
17+
- name: Setup PHP
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: ${{ matrix.php }}
21+
22+
- name: Setup problem matchers for PHPUnit
23+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
24+
25+
- name: Validate composer.json and composer.lock
26+
run: composer validate --strict
27+
28+
- name: Install Composer dependencies
29+
run: composer install --no-progress
30+
31+
- name: Run PHPUnit
32+
run: composer test
33+
34+
- name: Perform static analysis
35+
run: composer analyze -- --error-format=github
36+
if: ${{ matrix.php == '8.4' }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea/
2+
.phpunit.result.cache
3+
.php-cs-fixer.cache
4+
vendor/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Theodore Brown
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# handlebars.php
2+
3+
Parse and render [Handlebars](https://handlebarsjs.com) templates with PHP.
4+
5+
## Installation
6+
7+
`composer require devtheorem/handlebars.php`
8+
9+
## Usage
10+
11+
Todo
12+
13+
## Author
14+
15+
Theodore Brown

composer.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "devtheorem/handlebars.php",
3+
"description": "Minimal templating on steroids.",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Theodore Brown",
9+
"email": "theodorejb@outlook.com"
10+
}
11+
],
12+
"require": {
13+
"php": ">=8.2"
14+
},
15+
"require-dev": {
16+
"jbboehr/handlebars-spec": "dev-master",
17+
"phpstan/phpstan": "^2.1",
18+
"phpunit/phpunit": "^11.5"
19+
},
20+
"autoload": {
21+
"psr-4": {
22+
"DevTheorem\\Handlebars\\": "src/"
23+
}
24+
},
25+
"autoload-dev": {
26+
"psr-4": {
27+
"DevTheorem\\Handlebars\\Test\\": "test/"
28+
}
29+
},
30+
"scripts": {
31+
"analyze": "phpstan analyze src --level 10",
32+
"test": "vendor/bin/phpunit test"
33+
},
34+
"config": {
35+
"sort-packages": true
36+
}
37+
}

0 commit comments

Comments
 (0)