Use ContentType and contextual filters to control escaping
masterLatte uses ContentType to track the type of content being processed. ContentType is a final class containing string constants:
Html='html'Text='text'JavaScriptCssXmlICal
Contextual Filters
A contextual filter can interact with the FilterInfo object to declare the nature of its output. This is primarily used to:
- Disable auto-escaping: A filter can set
$info->contentType = ContentType::Htmlto signal that its output is already valid HTML, preventing Latte from escaping it again. - Validate input: Filters can use
FilterInfo::validateto assert what input type they accept.
Note: Enforcement of content types for filters applied to {block} is performed at runtime, not compile time. A filter might be accepted when the incoming content type is text but will throw an error if the content type does not match its requirements during execution.