Skip to content

1.2.0 Data Frames

Choose a tag to compare

@theodorejb theodorejb released this 30 Mar 05:22
· 39 commits to master since this release

Added

  • Handlebars::createFrame(): creates a child @data frame inheriting fields from a parent frame, equivalent to Handlebars.createFrame() in Handlebars.js.

Changed

  • To align with Handlebars.js, @data variables passed to fn() or inverse() by block helpers are no longer automatically merged with parent data and @root. For example, if a helper calls fn() with ['data' => ['index' => 0]] as the second parameter, @index will now be the only @data variable inside the block. To set @-prefixed variables while still inheriting parent @data variables, call Handlebars::createFrame($options->data) to create an isolated child frame. Then assign new keys to it before passing it to the data option of fn() or inverse().
  • Handlebars::escapeExpression() now uses strtr() instead of str_replace() for better performance.

Fixed

  • Block param path lookups and literal path lookups (e.g. {{"foo"}}, {{#"foo"}}) in strict mode no longer incorrectly throw when the key exists but its value is null.
  • Inline partials defined inside an {{else}} block no longer leak into the surrounding scope.