Five New Features in Latte 3.1 That Will Make Your Life Easier – Nette Blog
This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).
Latte 3.1 introduces five practical improvements to the PHP templating engine. The `ScopedLoopVariables` feature prevents foreach loop variables from leaking into the outer scope, restoring original values after the loop ends. The `Dedent` feature automatically removes common indentation inside paired tags at compile time with no runtime cost. Three new filters are added: `|commas` joins arrays with natural language separators (e.g., 'apple, pear and plum'), `|column` extracts a single column from arrays of records, and `|limit` takes the first N elements from arrays, iterators, or strings while preserving keys. The existing `|slice` filter is also extended to support iterators and generators with lazy memory-efficient evaluation. Both engine features are enabled via `setFeature()` or Nette configuration.
Table of contents
No More Variable Leaking from {foreach}Indent Your Templates However You LikeFilter |commasFilter |columnFilter |slice for Iterators and New Filter |limitHow to EnableSort: