@@ -10,7 +10,7 @@ PHP Handlebars compiles and executes complex templates up to 40% faster than Lig
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.1 | 3.5 ms | 1.6 ms | 5.1 ms | 3.6 MB |
13+ | PHP Handlebars 1.2 | 3.7 ms | 1.5 ms | 5.2 ms | 3.6 MB |
1414
1515_ Tested on PHP 8.5 with the JIT enabled. See the ` benchmark ` branch to run the same test._
1616
@@ -154,10 +154,9 @@ echo $template(['my_var' => null], $runtimeOptions); // Not equal
154154 (e.g. ` {{#helper as |a b|}} ` produces ` 2 ` ).
155155
156156* ` scope ` (` mixed ` ): The current evaluation context (equivalent to ` this ` in a Handlebars.js helper).
157- Can be reassigned inside a helper to change the context passed to ` fn() ` .
158157
159- * ` data ` (` array ` ): The current ` @data ` frame. Contains ` @ ` -prefixed private variables such as
160- ` root ` , ` index ` , ` key ` , ` first ` , ` last ` , and ` _parent ` . Can be read or modified inside a helper.
158+ * ` data ` (` array ` ): The current ` @data ` frame. ` root ` refers to the top-level context.
159+ ` index ` , ` key ` , ` first ` , and ` last ` are set by ` {{#each}} ` blocks . Can be read or modified inside a helper.
161160
162161### HelperOptions Methods
163162
@@ -177,7 +176,7 @@ echo $template(['my_var' => null], $runtimeOptions); // Not equal
177176 remainder of the render. The closure must be produced by ` Handlebars::compile ` .
178177
179178> [ !NOTE]
180- > ` isset($options->fn) ` and ` isset($options->inverse) ` return true if the helper was called as a block,
179+ > ` isset($options->fn) ` and ` isset($options->inverse) ` return ` true ` if the helper was called as a block,
181180> and ` false ` for inline helper calls.
182181
183182## Hooks
@@ -222,6 +221,13 @@ Helpers may return a `DevTheorem\Handlebars\SafeString` instance to prevent esca
222221When constructing the string that will be marked as safe, any external content should be properly escaped
223222using the ` Handlebars::escapeExpression() ` method to avoid potential security concerns.
224223
224+ ## Data Frames
225+
226+ Block helpers that inject ` @ ` -prefixed variables should create a child data frame using
227+ ` Handlebars::createFrame($options->data) ` , add their variables to it, and pass it to ` fn() ` or ` inverse() `
228+ via the ` data ` key (e.g. ` $options->fn($context, ['data' => $frame]) ` ). This mirrors ` Handlebars.createFrame() `
229+ in Handlebars.js, isolating the helper's variables while still inheriting parent data such as ` @root ` .
230+
225231## Missing Features
226232
227233All syntax and language features from Handlebars.js 4.7.9 should work the same in PHP Handlebars,
0 commit comments