Content Directives #
Content directives replace the element contents with a single value.
Directives #
-
s:text- Escaped output. -
s:html- Raw HTML output.
Examples #
s:text #
Output escaped text from a value.
<div s:text="$userName"></div>
<div s:text="$userName ?? 'Guest'"></div>
<!-- $userName = '<Alice>' -->
<div><Alice></div>
s:html #
Output raw HTML from a trusted value.
Only use s:html with trusted content.
<div s:html="$article->renderedContent"></div>
<div s:html="$snippet"></div>
<!-- $snippet = '<strong>Hello</strong>' -->
<div><strong>Hello</strong></div>
Related Pass-through Directive #
s:raw is a pass-through directive (not a content replacement directive), but it is commonly used with content directives when you need literal inner markup.
No Wrapper Output #
Add s:nowrap to render content without the surrounding element:
<div s:text="$headline" s:nowrap></div>
<!-- $headline = 'News' -->
News