Skip to content

Engine: added renderToContent() - #432

Open
vrana wants to merge 3 commits into
nette:masterfrom
vrana:render-to-content
Open

vrana wants to merge 3 commits into
nette:masterfrom
vrana:render-to-content

Conversation

@vrana

@vrana vrana commented Oct 29, 2026

Copy link
Copy Markdown
Member

vrana and others added 3 commits October 29, 2026 09:25
Content is a string tagged with its content type, so a trusted value is not
tied to HTML. Html is Content of type HTML; it still implements HtmlStringable,
so printing it is unchanged. Content of another type is a plain Stringable and
is escaped as text for now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wn context

Like Html in HTML text, Content of the other types is trusted where its type
is expected: JS in <script>, in a print inside on* and in a JS template (through
convertJSToRawText, then attribute-encoded in on*), CSS likewise, XML in XML
and iCal in iCal. A block from <script> or <style> (html/raw/js, html/raw/css)
counts as JS or CSS. Content of any other type is still escaped as text.

The escapers list the types they accept instead of asking getConvertor(),
because escapeJs serves js, html/raw/js and html/attr/js without knowing which.

filterContent() passes Content of the filtered type to the filter as a string.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Returns the output as Content of its effective content type: the layout's
with {extends}, or the block's when rendering a single block. HTML is returned
as Html, so it can be printed without new Html(renderToString()).

With $contentType, the output is converted to it like {include} does (a text
template is escaped into HTML), or it throws if the types are incompatible.
Template::render() applies the conversion at the end of the extends chain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant