Skip to main content

Rendering raw HTML

To render HTML that has come from a trusted source, bypassing all HTML escaping and security mechanisms that templ includes, use the templ.Raw function.

info

Only include HTML that comes from a trusted source.

warning

Use of this function may introduce security vulnerabilities to your program.

component.templ
templ Example() {
<!DOCTYPE html>
<html>
<body>
@templ.Raw("<div>Hello, World!</div>")
</body>
</html>
}
Output
<!DOCTYPE html>
<html>
<body>
<div>Hello, World!</div>
</body>
</html>