Major improvements:
- Add string position of tokens in token trees by @synga-nl in twigjs#859
- Allow multiple spaces after elseif statement. by @antoineveldhoven in twigjs#870
- Make is empty return false for boolean true. by @antoineveldhoven in twigjs#869
- Add support for spaceship operator by @antoineveldhoven in twigjs#873
- Allow colon inside Twig.expression.type.key.brackets. by @antoineveldhoven in twigjs#879
- Support variables in slice filter shorthand by @antoineveldhoven in twigjs#881
Minor improvements:
- Bump @babel/traverse from 7.12.5 to 7.23.2 by @dependabot in twigjs#877
Major improvements:
- Fix passing context around by @willrowe in twigjs#850
- Add namespace support to
sourcefunction by @willrowe in twigjs#823 - Use src/twig.js as package's main script instead of the compiled twig.js by @RobLoach in twigjs#829
Minor improvements:
- Fix macro changing context in loop by @mihkeleidast in twigjs#773
- Imported function PATHS.strip_slash() missing by @murageyun in twigjs#770
- Convert non-string values to string before replacing by @kmonahan in twigjs#797
- Add GitHub actions test workflow by @willrowe in twigjs#817
- Fix date parsing with timezones by @plepe in twigjs#765
- Fixed Twig official's URL on README.md by @Geolim4 in twigjs#822
- Add tests for whitespace in paths by @willrowe in twigjs#824
- Fix multiple includes with embeds by @willrowe in twigjs#828
- Update to Mocha 9.x by @RobLoach in twigjs#831
- Add test for issue #767 by @willrowe in twigjs#837
- Add support for
divisible bytest by @willrowe in twigjs#838 - Add support for
withtag without context oronlykeyword by @willrowe in twigjs#839 - Use v3 of
actions/checkoutby @willrowe in twigjs#846 - Test on more node versions by @willrowe in twigjs#847
- Fix webpack 5 compatibility by @willrowe in twigjs#849
- Add test to confirm
renderFileerror handling by @willrowe in twigjs#851 - Fix casing of variables in docs by @willrowe in twigjs#852
- Bumped dependencies by @dependabot
Minor improvements:
- Fix lost context when calling a macro multiple times (#727) by mihkeleidast
Minor improvements:
- Fix documentation of browser usage (#755) by odebparla
- Add support for template arrays when using extends (#754) by justafish
Minor improvements:
- Specify MimeType to always use for AJAX templates (#742) by MasterOdin
- Added token count validation (#745) by HakS
- Async renderFile error callback (#748) by ArnauMrJeff
- Ternary operator overrides context fix (#737) by oleg-andreyev
- Update lodash to
4.17.19 - Update elliptic to
6.5.3
Major improvements:
- Make "js" escaped strings embeddable in JSON (#724 by [@dorian-marchal])
Minor improvements:
- Fix parsing expression when value is
null(#735 by [@RobLoach])
Major improvements:
- Add support for arrays with
include(#681 by @justafish) - Add babel preset on serverBuild (#707 by @stephane-r)
- Support for "do" tag (#703 by @drzraf)
- Update
xoand code syntax by @RobLoach - Deprecate Node.js 8 from testing by @RobLoach
- Support for Source Maps (#700 by @drzraf)
- Search for block within all ascendants instead of parent only (#698 by @drzraf)
Minor improvements:
- Fix autoescape for empty includes (#687 by @tgabi333)
- Fix filters with empty string input (#690 by @tbence94)
Major improvements:
- Add Babel to the webpack build
Minor improvements:
- Add
applytag (#656 by @maxhelias) - Add
spacelessfilter (#655 by @maxhelias) - Add
deprecatedtag (#675 by @josephineb) - Fix
starts withandends withexpressions (#661 by @ilkkave) - Add
package.jsonlicense field to fix npm warning (#672 by @WietseWind) - Update
strict_variablesoption to match Twig's strict messages (#674 by @toptalo) - Fix
??operator when used with arrays to return the array rather than its length (#653 by @diegorales)
Minor improvements:
- Allow project development on Windows (#611)
- Add possibility to define namespace without slash at the end of the path (#609)
- Update
verbatimtag (#584)
Minor improvements:
- fix for not autoescaping includes having a parent (#606)
Minor improvements:
- Fix for not autoescaping includes (#604)
Major improvements:
- Unminified sources in the npm package (#598)
Minor improvements:
- Multiple namespace performance improvement (#580)
|url_encodecan now extend parameters (#588)- Fix
.startsWithand.endsWithwith.indexOffor IE (#587) - Autoescaping improvement (#577)
- Support null-coalescing operator
??(#575) - Add
verbatimtag (#574) - Fix bug in
forloop (#573) - Fix twig
{% if(x) %}and{% elseif(x) %}blocks parsing error (#570)
Major improvements:
- Fix array declaration on multiple lines (#546)
- Fix extend when add is null (#559)
Minor improvements:
- Improve namespaces support (#556)
- Allow express to render async (#558)
Major improvements:
- Upgrade to Webpack 4 (#542)
- Fix embed blocks logic (#537)
Minor improvements:
- Improve detection of when a block is in a loop (#541)
- Add possibility to set default value for a macro parameter (#544)
Major improvements:
- Add support for 'with' tag (#497)
- Add date support for json_encode filter (#515)
- Fix 'embed' tag options (#534)
- Performance improvements when including templates (#492)
Minor improvements:
- Fix incorrect 'and' and 'or' behaviour when comparing variables (#481)
- Remove 'trim' filter autoescape (#488)
- Fix empty output from loop with async call (#538)
- Add allowable tags to strip tags filter (#524)
Minor improvements:
- Template id is now returned as part of the error when an exception is thrown (#464)
- Test result no longer dependent on the name of the test file (#465)
- Fix unexpected 'const' (#471)
Minor improvements:
- Fixed missing changelog updates
Major improvements:
- Async rendering and filters (#457)
- From aliases (#438)
- Bitwise operators (#443)
- Fix object method context (#455)
Minor improvements:
- Readme updates (#454)
- 'not' unary can be more widely used (#444)
- Fix
importFilerelative path handling (#449)
Minor improvements:
- Spaceless tag no longer escapes Static values (#435)
- Inline includes now load (#433)
- Errors during async fs loading use error callback (#431)
Minor improvements:
- Support 'same as' (#429)
- Fix windows colon colon namespace (#430)
Minor improvements:
- Fixed missing changelog updates
- Fixed incorrect versions in source
- Rethrow errors when option to do so is set (#422)
Bower is no longer supported
Major improvements:
- Updated to locutus which replaces phpjs
- elseif now accepts truthy values (#370)
- Use PHP style falsy matching (#383)
- Fix 'not' after binary expressions (#385)
- Use current context when parsing an include (#395)
- Correct handling of 'ignore missing' in embed and include (#424)
Minor improvements:
- Documentation updates
- Refreshed dependencies
Minor improvements:
- Templates that are included via "extends" now populate the parent template context
Parentheses parsing has undergone quite a large refactoring, but nothing should have explicitly broken.
Major improvements:
- Subexpressions are now supported and parsed differently from function parameters
Fix missing changelog updates
Minor improvements:
- Empty strings can now be passed to the date filter
- Twig.expression.resolve keeps the correct context for
this
Fixed changelog versioning
Theoretically no breaking changes, but lots of things have changed so it is possible something has slipped through.
Dependencies have been updated. You should run npm install to update these.
Major improvements:
- Webpack is now used for builds
- phpjs is now a dependency and replaces our reimplementation of PHP functions (#343)
- Arrays are now cast to booleans unless accessing their contents
- in/not in operator precedence changed (#344)
- Expressions can now be keys (#350)
- The extended ternary operator is now supported (#354)
- Expressions can now appear after period accessor (#356)
- The slice shorthand is now supported (#362)
Minor improvements:
- Twig.exports.renderFile now returns a string rather than a String (#348)
- The value of context is now cloned when setting a variable to context (#345)
- Negative numbers are now correctly parsed (#353)
- The // operator now works correctly (#353)
Dependencies have been updated to current versions. You should run npm install to update these. (#313)
Major improvements:
- Twig's
sourcefunction is now supported (#309) - It is possible to add additional parsers using Twig.Templates.registerParser() (currently available: twig, source). If you are using a custom loader, please investigate src/twig.loader.fs.js how to call the requested parser. (#309)
undefinedandnullvalues now supported in theinoperator (#311)- Namespaces can now be defined using the '@' symbol (#328)
Minor improvements:
- Undefined object properties now have the value of
undefinedrather thannull(#311) - Improved browser tests (#325, #310)
- IE8 fix (#324)
- Path resolution has been refactored to its own module (#323)
Major improvements:
- Support for block shortcuts:
{% block title page_title|title %}(#304) - Define custom template loaders, by registering them via
Twig.Templates.registerLoader()(#301)
Minor improvements:
- Some mocha tests didn't work in browsers (#281)
- Fix Twig.renderFile (#303)
Major improvements:
- The
autoescapeoption now supports all strategies which are supported by theescapefilter (#299)
Minor improvements:
- The
datefilter now recognises unix timestamps as input, when they are passed as string (#296) - The
defaultfilter now allows to be called without parameters (it will return an empty string in that case) (#295) - Normalize provided template paths (this generated problems when using nodejs under Windows) (#252, #300)
Major improvements:
- The
escapefilter now supports the strategy parameter:{{ var|escape('css') }}with the following available strategies: html (default), js, css, url, html_attr. (#289)
Minor improvements:
- The filter
url_encodenow also encodes apostrophe (as in Twig.php) (#288) - Minor bugfixes (#290, #291)
From 0.8.5 on, a summary of changes between each version will be included in the CHANGELOG.md file.
There were some changes to the Contribution guidelines: please commit only changes to source files, the files twig.js and twig.min.js will be rebuilt when a new version gets released. Therefore you need to run make after cloning resp. pulling (if you want to use the development version).
Major improvements:
- Implement
minandmaxfunctions (#164) - Support for the whitespace control modifier:
{{- -}}(#266) sortfilter: try to cast values to match type (numeric values to number, string otherwise) (#278)- Support for twig namespaces (#195, #251)
- Support for expressions as object keys:
{% set foo = { (1 + 1): 'bar' } %}(#284)
Minor improvements:
- Allow integer 0 as key in objects:
{ 0: "value" }(#186) json_encodefilter: always return objects in order of keys, also ignore the internal key_keysfor nested objects (#279)datefilter: update to current strtotime() function from phpjs: now support ISO8601 dates as input on Mozilla Firefox. (#276)- Validate template IDs only when caching is enabled (#233, #259)
- Support xmlhttp.status==0 when using cordova (#240)
- Improved sub template file loading (#264)
- Ignore quotes between
{% raw %}and{% endraw %}(#286)