Documentation menu

Raw HTML

In some cases, you may want to render raw html instead of using htmgo's functions.

This can be done by using the following methods:

Rendering raw html:

h.UnsafeRaw("<div>Raw HTML</div>")
Copy

Rendering with formatting:

h.UnsafeRawF("<div>%s</div>", "Raw HTML")
Copy

Rendering a script:

h.UnsafeRawScript("alert('Hello World')")
Copy

Use h.Text to render untrusted values as escaped text. When you intend to render user-supplied HTML markup, sanitize it before passing it to the raw HTML helpers.

For example, bluemonday lets you define which HTML elements and attributes to allow.