https://github.com/codemix/handlebarsphp
Transpiles handlebars templates into native PHP templates
https://github.com/codemix/handlebarsphp
Last synced: 12 months ago
JSON representation
Transpiles handlebars templates into native PHP templates
- Host: GitHub
- URL: https://github.com/codemix/handlebarsphp
- Owner: codemix
- Created: 2013-07-02T20:26:12.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-07-06T00:13:49.000Z (over 12 years ago)
- Last Synced: 2025-03-24T08:54:52.647Z (12 months ago)
- Language: PHP
- Size: 112 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HandlebarsPHP
### Note: this is alpha quality software, use at your own risk.
Turns handlebars templates into executable PHP code ahead of time, ships with built in support for Yii 1.x.
but allows customisation of output to support different frameworks.
# Installation
Install via composer, package name is `codemix/handlebarsphp`.
# Differences from HandlebarsJS
HandlebarsPHP aims to be compatible with a subset of HandlebarsJS. For performance reasons it compiles the templates
ahead of time and this necessitates some restrictions.
1. Since it's impossible to tell whether a tag like `{{foo}}` is a helper or a property at compile time, we assume
that its a property. We differentiate helpers by looking for arguments, for example `{{foo 1}}` will be interpretted
as a function call because it has an argument. This means that it is impossible to call a helper with zero arguments.
2. `{{@key}}` and `{{@index}}` always point to the same variable, because `foreach` is used for all iteration.