add docs about raw html

This commit is contained in:
maddalax 2024-09-28 20:52:11 -05:00
parent 3d62d4edde
commit 073151cf14

View file

@ -0,0 +1,22 @@
**Rendering 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:
```go
h.UnsafeRaw(string)
h.UnsafeRawF(string, ...interface{})
h.UnsafeRawScript(string)
```
Usage:
```go
h.UnsafeRaw("<div>Raw HTML</div>")
h.UnsafeRawF("<div>%s</div>", "Raw HTML")
h.UnsafeRawScript("<script>alert('Hello World')</script>")
```
Important: Be careful when using these methods, these methods do not escape the HTML content
and should **never** be used with user input unless you have sanitized the input.
Sanitizing input can be done using the `html.EscapeString` function or by using https://github.com/microcosm-cc/bluemonday.