class

Crinja::Renderer

Inherits Reference < Object

A - strips ALL whitespace on its side, newlines included. Upstream only trimmed the adjacent line (StringTrimmer.trim partitions at the first / last newline), so a\n{%- if x %} kept the newline and {% for … -%}\n {{ i }} kept the indent: templates written for Jinja2 rendered with stray blank lines. A side without - keeps the upstream trim_blocks / lstrip_blocks handling (hwaro sets neither).

Class methods

trim_text(node, trim_blocks = false, lstrip_blocks = false)
Source

Instance methods

render(node : AST::FixedString)

=== 2. FixedString trim memoization ================================== Static template text is re-trimmed (allocating a fresh String) every time its node renders — for a loop body that means once per iteration, for a listing template once per page per item. The trim result depends only on the node and the two config flags, so cache the RenderedOutput on the node keyed by those flags. RenderedOutput is immutable, so sharing one instance across OutputLists (and across fibers — the write is an idempotent benign race) is safe.

Source
render(node : AST::PrintStatement)

=== 1. PrintStatement fast path ====================================== Upstream stringifies every printed value through Finalizer via String.build, which copies the string even in the overwhelmingly common case: a String (or SafeString) value with autoescape disabled, where Finalizer writes the bytes verbatim (quote only adds quotes inside structs, never at the top level). Return the string itself instead of copying it. Non-string values and autoescaped output keep the original path.

Source

Nested types