Raw
Marks a string as trusted HTML, bypassing escaping when interpolated inside html. Use it when you need to inject markup you fully control — icons, pre-rendered fragments, or server-sanitized content.
Basic usage
Without raw(), the same string would be escaped:
When to use it
raw() is appropriate when the markup comes from a source you fully control:
When not to use it
Never pass user input to raw(). It disables all escaping, so any unescaped string becomes a potential XSS vector:
Composing with html
html results are already treated as safe and pass through unescaped without needingraw(). Reserve raw() for plain strings that contain trusted markup:
Return type
raw() returns a RawHtml object — the same type produced by html. This means raw values compose freely with nested templates and arrays:
Notes
raw()only has an effect insidehtml. Outside of a template it simply wraps the string in aRawHtmlobject with no other transformation.- There is no runtime sanitization inside
raw(). If you need to accept user-generated HTML, sanitize it with a dedicated library such as DOMPurify before passing it toraw().