Skip to content

Commit b5fe5d9

Browse files
committed
Release 1.2.1
1 parent e6c36b4 commit b5fe5d9

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
55

6+
## [1.2.1] Optimal Simplification - 2026-04-02
7+
8+
### Changed
9+
- Updated to PHP Handlebars Parser 2.0, which removed unnecessary options state from the parser and made it
10+
possible to reuse the same parser instance when compiling multiple templates (e.g. for runtime partials).
11+
The PHP Handlebars API hasn't changed, but it now performs better and has significantly lower memory
12+
usage when compiling two or more templates.
13+
- `Options`, `HelperOptions`, and `SafeString` are now `final`, since there's no reason to ever extend them.
14+
15+
### Removed
16+
- Unnecessary internal `StringObject` class.
17+
18+
619
## [1.2.0] Data Frames - 2026-03-30
720

821
### Added
@@ -203,6 +216,7 @@ Initial release after forking from LightnCandy 1.2.6.
203216
- HTML documentation.
204217
- Dozens of unnecessary feature flags.
205218

219+
[1.2.1]: https://github.com/devtheorem/php-handlebars/compare/v1.2.0...v1.2.1
206220
[1.2.0]: https://github.com/devtheorem/php-handlebars/compare/v1.1.0...v1.2.0
207221
[1.1.0]: https://github.com/devtheorem/php-handlebars/compare/v1.0.1...v1.1.0
208222
[1.0.1]: https://github.com/devtheorem/php-handlebars/compare/v1.0.0...v1.0.1

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ A blazing fast, spec-compliant PHP implementation of [Handlebars](https://handle
55
Originally based on [LightnCandy](https://github.com/zordius/lightncandy), but rewritten to enable
66
full Handlebars.js compatibility without excessive feature flags or performance tradeoffs.
77

8-
PHP Handlebars compiles and executes complex templates up to 40% faster than LightnCandy:
8+
PHP Handlebars compiles and executes complex templates up to 40% faster than LightnCandy, with 60% lower memory usage:
99

1010
| Library | Compile time | Runtime | Total time | Peak memory usage |
1111
|--------------------|--------------|---------|------------|-------------------|
1212
| LightnCandy 1.2.6 | 5.2 ms | 2.8 ms | 8.0 ms | 5.3 MB |
13-
| PHP Handlebars 1.2 | 3.7 ms | 1.5 ms | 5.2 ms | 3.6 MB |
13+
| PHP Handlebars 1.2 | 3.3 ms | 1.5 ms | 4.8 ms | 1.9 MB |
1414

1515
_Tested on PHP 8.5 with the JIT enabled. See the `benchmark` branch to run the same test._
1616

@@ -106,7 +106,7 @@ echo $template(['first' => 'John']); // Error: "last" not defined
106106
`Handlebars::compile` returns a closure which can be invoked as `$template($context, $options)`.
107107
The `$options` parameter takes an array of runtime options, accepting the following keys:
108108

109-
* `data`: An associative array of initial `@data` variables (e.g. `['version' => '1.0']` makes `@version` available in the template).
109+
* `data`: An associative array of custom `@data` variables (e.g. `['version' => '1.0']` makes `@version` available in the template).
110110

111111
* `helpers`: An `array<string, \Closure>` of helpers to merge with the built-in helpers. Can also be used to override a built-in helper by using the same name.
112112

@@ -218,8 +218,8 @@ If a custom helper is executed in a `{{ }}` expression, the return value will be
218218
When a helper is executed in a `{{{ }}}` expression, the original return value will be output directly.
219219

220220
Helpers may return a `DevTheorem\Handlebars\SafeString` instance to prevent escaping the return value.
221-
When constructing the string that will be marked as safe, any external content should be properly escaped
222-
using the `Handlebars::escapeExpression()` method to avoid potential security concerns.
221+
Because `SafeString` bypasses the automatic HTML escaping that `{{ }}` applies, any user-supplied content
222+
embedded in it must first be escaped with `Handlebars::escapeExpression()` to prevent XSS vulnerabilities.
223223

224224
## Data Frames
225225

0 commit comments

Comments
 (0)