Releases: devtheorem/php-handlebars
Releases · devtheorem/php-handlebars
1.0.1 Root SubExpression
Fixed
- Support for sub-expressions that are
PathExpressionroots (e.g.{{(my-helper foo).bar}}). - Compilation of multi-segment
if/unlessconditions (#15). - Helper argument handling in
strictmode. assumeObjectserrors now align better with Handlebars.js.
1.0.0 AST Compiler
Rewrote the parser and compiler to use an abstract syntax tree, based on the same lexical analysis and grammar specification as Handlebars.js. This eliminates a large class of edge cases and parsing bugs that the old regex-based approach failed to handle correctly.
This release is 35-40% faster than v0.9.9 and LightnCandy at compiling and executing complex templates, and uses almost 30% less memory. The code is also significantly simpler and easier to maintain.
Added
- Support for nested inline partials.
- Support for closures in data and helper arguments.
helperMissingandblockHelperMissinghooks: handle calls to unknown helpers with the same API as in Handlebars.js, replacing the oldhelperResolveroption.knownHelperscompile option: tell the compiler which helpers will be available at runtime for more efficient execution (helper existence checks can be skipped).assumeObjectscompile option: a subset ofstrictmode that generates optimized templates when the data inputs are known to be safe.- Support for deprecated
{{person/firstname}}path expressions for parity with Handlebars.js (avoid using this syntax in new code, though).
Changed
- Custom helpers must now be passed at runtime when invoking a template (via the
helpersruntime option key), rather than via theOptionsobject passed tocompileorprecompile. This is a significant optimization, since it eliminates the overhead of reading and tokenizing PHP files to extract helper functions. It also enables sharing helper closures across multiple templates and renders, and removes limitations on what they can access and do (e.g. it resolves zordius/lightncandy#342). - Exceptions thrown by custom helpers are no longer caught and re-thrown, so the original exception can now be caught in your own code for easier debugging (#13).
- The
partialResolverclosure signature no longer receives an internalContextargument. Now only the partial name is passed. knownHelpersOnlynow works as in Handlebars.js, and an exception will be thrown if the template uses a helper which is not in theknownHelperslist.- Updated various error messages to align with those output by Handlebars.js.
Removed
Options::$helpers: instead pass custom helpers when invoking a template, using thehelperskey in the runtime options array (the second argument to the template closure).Options::$helperResolver: use thehelperMissing/blockHelperMissingruntime helpers instead.
Fixed
- Fatal error with deeply nested
else ifusing custom helper (#2). - Incorrect rendering of float values (#11).
- Conditional
@partial-blockexpressions. - Support for
@partial-blockin nested partials (zordius/lightncandy#292). - Ability to precompile partials and pass them at runtime (zordius/lightncandy#341).
- Fatal error when a string parameter to a partial includes curly braces (zordius/lightncandy#316).
- Behavior when modifying root context in a custom helper (zordius/lightncandy#350).
- Escaping of block params and partial names.
- Inline partials defined inside a
{{#with}}or other block leaking out of that block's scope after it closes. - Numerous other bugs related to scoping, block params, inverted block helpers, section iteration, and depth-relative paths.
0.9.9 Stringable Conditions
0.9.8 String Escaping
Added
Handlebars::escapeExpression()method (equivalent to theHandlebars.escapeExpression()utility function in Handlebars.js).
Removed
- Unnecessary
$escapeparameter on SafeString constructor.
Fixed
- Nested else if validation (fixes zordius/lightncandy#313).
- Escaping multiple double quotes (fixes zordius/lightncandy#298).
- Single-quoted string parsing and compiling.
0.9.7 Resolvers
Added
helperResolverandpartialResolvercompile options for dynamic handling of partials and helpers (#1).
0.9.6 Partial Indentation
Fixed
- Indentation of nested partials (fixes zordius/lightncandy#349).
- Parsing hash options containing line breaks (fixes zordius/lightncandy#310).
- Parameter type error in strict mode.
- Parsing raw block helper params.
0.9.5 Block Parameter Parsing
Fixed
- Parsing block parameters with extra surrounding whitespace (fixes zordius/lightncandy#371).
0.9.4 String Arguments
Fixed
- Parsing single-quoted string arguments (fixes zordius/lightncandy#281, zordius/lightncandy#357, zordius/lightncandy#367).
0.9.3 Raw Block Parsing
Fixed
- Correctly parse handlebars after raw block (fixes zordius/lightncandy#344).
0.9.2 Arrow Function Helpers
Added
- Support for arrow function helpers (fixes zordius/lightncandy#366).
Fixed
- Parse error when using length with
@root(from zordius/lightncandy#370).