Latte 3.1.3 brings two powerful new engine features – automatic dedentation and scoped loop variables – alongside a fresh batch of filters that make everyday template work smoother.
✨ New Features
- Feature::Dedent – removes structural indentation from paired tag content, so your generated HTML stays clean regardless of how deeply you nest your Latte tags
- Feature::ScopedLoopVariables – variables introduced by
{foreach}now live only inside the loop body, preventing accidental leaks into the surrounding scope (supports destructuring viaListNodetoo) - |commas filter – joins array elements with
,and supports a custom last-item glue (e.g.{$items|commas:' and '}→a, b and c) - |column filter – extracts values from a single column of a multidimensional array or iterable, mirroring PHP's
array_column() - |limit filter – a friendlier wrapper around
|slicewith swapped arguments: limit first, offset second, and keys preserved by default - |slice – now works with iterators, not just arrays and strings
- |padLeft, |padRight – now accept
int|floatvalues in addition to strings (#408)
♻️ Code Refactoring
- Helpers::sortBeforeAfter() – reimplemented using Kahn's algorithm for topological sorting, making extension ordering both faster and more correct
- Engine::addDefaultExtensions() – extracted into its own method for better extensibility