github nette/latte v3.1.0
Released version 3.1.0

10 hours ago

This major release introduces Smart HTML Attributes, strict_types by default, and several syntax improvements. It requires PHP 8.2+.

Smart HTML Attributes

  • Null values: Attributes with null values are now dropped instead of rendering as empty strings.
  • Boolean attributes: Attributes like checked or disabled render conditionally based on truthy/falsey values.
  • Array support: class and style attributes now accept arrays (e.g., class="{[active: $cond]}").
  • Data attributes: data-* attributes automatically JSON-serialize non-string values (arrays, objects, booleans).
  • Aria attributes: aria-* attributes render boolean values as "true"/"false".
  • Type checking: Passing invalid types (arrays, objects) to standard attributes now triggers a warning and omits the attribute.

New Features

  • Added n:elseif support.
  • Added nullsafe filter operator ?| (e.g., {$var?|upper}).
  • Added |toggle filter for manual boolean attribute control.
  • Support for unquoted n-attribute syntax: n:if={$cond}.
  • Added Engine::setMigrationWarnings() to help detect changes in attribute rendering.

Breaking Changes & Deprecations

  • strictTypes is now enabled by default.
  • Using $this and $__* variables in templates is deprecated.
  • The undefined unsafe operator ??-> is deprecated (use ?->).
  • Global constants should now be prefixed with a slash (e.g., \PHP_VERSION).
  • Engine::addFilterLoader() is deprecated.

Don't miss a new latte release

NewReleases is sending notifications on new releases.