add docs about raw html
This commit is contained in:
parent
3d62d4edde
commit
073151cf14
1 changed files with 22 additions and 0 deletions
22
htmgo-site/md/docs/2_core-concepts/6_raw_html.md
Normal file
22
htmgo-site/md/docs/2_core-concepts/6_raw_html.md
Normal 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.
|
||||
Loading…
Reference in a new issue