Implements the compiler-reserved final output-context filter.
The trusted compiler appends this filter after every delivery expression. User source cannot name it directly. It escapes or validates the final value after ordinary Liquid filters have run, which prevents a preceding filter from bypassing the context selected during compilation.
This module is part of the renderer implementation. Template authors should declare the correct variable context instead of calling it.
Examples
iex> Letterpress.Renderer.Filters.escape("<Ada & Grace>", "html_text")
{:ok, "<Ada & Grace>"}
iex> Letterpress.Renderer.Filters.escape("javascript:alert(1)", "url")
:error
Summary
Functions
Implements the custom-filter callback expected by Solid.render/3.
Escapes or validates a value for a compiler-proven context.
Functions
Implements the custom-filter callback expected by Solid.render/3.
Only the compiler-reserved "letterpress_escape" filter and its two
arguments are accepted.
Escapes or validates a value for a compiler-proven context.
HTML text and attribute contexts are escaped. Subjects reject CR, LF, NUL, and oversized output. URLs reject control characters, protocol-relative values, and absolute schemes outside the render call's allowlist.
Example
iex> Letterpress.Renderer.Filters.escape("https://example.test/?a=1&b=2", "url")
{:ok, "https://example.test/?a=1&b=2"}