✨ New Features
- Extension::getAttributeContentTypes() – tell Latte that your custom attributes hold JavaScript, CSS or HTML, and it escapes them exactly like
onclick,styleorsrcdoc. Map names or prefixes, such as'x-on:*' => ContentType::JavaScriptfor Alpine or'data-tippy-content' => ContentType::Htmlfor Tippy, and it works in static values,name={$x}andn:attralike (#426)
⚠️ Behavior Changes
- srcdoc – trusted HTML passed as a plain string is now displayed as text (see Security). Wrap it in
Latte\Runtime\Htmlor use|noescape; anHtmlobject now keeps its tags. With migration warnings on, Latte reports every value whose output changes (#425) - A
nullURL attribute is omitted like any other attribute:<a href={$url}>withnullrenders nohrefinstead ofhref="". Migration warnings report it (#428) - Deprecated: a positional argument after a named one in
{include},{embed},{extends},{layout},{import}and{sandbox}, as PHP forbids such a call; it will be an error in the next minor version
🔒 Security
- The
srcdocattribute is escaped twice, as the browser decodes it twice, so<iframe srcdoc="<p>{$x}</p>">cannot smuggle in a<script>(#425) - Vue, petite-vue and AngularJS can no longer find a
{{formed by adjacent outputs such as{$a}{$b}, or printed from a variable inside<script type="text/template">
🐛 Bug Fixes
- Braces in
<textarea>and<title>are printed as they are, so a value like{{ }}passes through a form unchanged (#409) - Blocks and includes in XML templates have the XML content type, so included text is converted by XML rules and including XML into XML works; mixing XML and HTML still works with a deprecation (#433)
|numberand|byteswith a locale round a half away from zero, the same as without one, and are much faster on repeated calls (#427)- Whitespace: the newline after an indented end tag such as
</ul>{/if}is kept, and the indentation of a line like{/block}</p>stays inside the block (#344) - Loading the same template from concurrent Swoole coroutines or fibers works (#404)
Thanks to @vrana for the attribute content types and the srcdoc, URL and XML escaping (#425, #426, #428, #433), and to @vosikar and @zipper for #427 and #424.