mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
This commit is contained in:
@@ -3,23 +3,17 @@ title: safe.CSS
|
||||
description: Declares the given string as a safe CSS string.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [safeCSS]
|
||||
related:
|
||||
- functions/safe/HTML
|
||||
- functions/safe/HTMLAttr
|
||||
- functions/safe/JS
|
||||
- functions/safe/JSStr
|
||||
- functions/safe/URL
|
||||
returnType: template.CSS
|
||||
signatures: [safe.CSS INPUT]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [safeCSS]
|
||||
returnType: template.CSS
|
||||
signatures: [safe.CSS INPUT]
|
||||
aliases: [/functions/safecss]
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
{{% include "functions/_common/go-html-template-package.md" %}}
|
||||
{{% include "/_common/functions/go-html-template-package.md" %}}
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -34,8 +28,6 @@ Use of this type presents a security risk: the encapsulated content should come
|
||||
|
||||
See the [Go documentation] for details.
|
||||
|
||||
[Go documentation]: https://pkg.go.dev/html/template#CSS
|
||||
|
||||
## Example
|
||||
|
||||
Without a safe declaration:
|
||||
@@ -51,9 +43,8 @@ Hugo renders the above to:
|
||||
<p style="ZgotmplZ">foo</p>
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
`ZgotmplZ` is a special value that indicates that unsafe content reached a CSS or URL context at runtime.
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> `ZgotmplZ` is a special value that indicates that unsafe content reached a CSS or URL context at runtime.
|
||||
|
||||
To declare the string as safe:
|
||||
|
||||
@@ -67,3 +58,5 @@ Hugo renders the above to:
|
||||
```html
|
||||
<p style="color: red;">foo</p>
|
||||
```
|
||||
|
||||
[Go documentation]: https://pkg.go.dev/html/template#CSS
|
||||
|
@@ -3,23 +3,17 @@ title: safe.HTML
|
||||
description: Declares the given string as a safeHTML string.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [safeHTML]
|
||||
related:
|
||||
- functions/safe/CSS
|
||||
- functions/safe/HTMLAttr
|
||||
- functions/safe/JS
|
||||
- functions/safe/JSStr
|
||||
- functions/safe/URL
|
||||
returnType: template.HTML
|
||||
signatures: [safe.HTML INPUT]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [safeHTML]
|
||||
returnType: template.HTML
|
||||
signatures: [safe.HTML INPUT]
|
||||
aliases: [/functions/safehtml]
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
{{% include "functions/_common/go-html-template-package.md" %}}
|
||||
{{% include "/_common/functions/go-html-template-package.md" %}}
|
||||
|
||||
## Usage
|
||||
|
||||
|
@@ -3,28 +3,22 @@ title: safe.HTMLAttr
|
||||
description: Declares the given key-value pair as a safe HTML attribute.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [safeHTMLAttr]
|
||||
related:
|
||||
- functions/safe/CSS
|
||||
- functions/safe/HTML
|
||||
- functions/safe/JS
|
||||
- functions/safe/JSStr
|
||||
- functions/safe/URL
|
||||
returnType: template.HTMLAttr
|
||||
signatures: [safe.HTMLAttr INPUT]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [safeHTMLAttr]
|
||||
returnType: template.HTMLAttr
|
||||
signatures: [safe.HTMLAttr INPUT]
|
||||
aliases: [/functions/safehtmlattr]
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
{{% include "functions/_common/go-html-template-package.md" %}}
|
||||
{{% include "/_common/functions/go-html-template-package.md" %}}
|
||||
|
||||
## Usage
|
||||
|
||||
Use the `safe.HTMLAttr` function to encapsulate an HTML attribute from a trusted source.
|
||||
|
||||
|
||||
Use of this type presents a security risk: the encapsulated content should come from a trusted source, as it will be included verbatim in the template output.
|
||||
|
||||
See the [Go documentation] for details.
|
||||
|
@@ -3,23 +3,17 @@ title: safe.JS
|
||||
description: Declares the given string as a safe JavaScript expression.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [safeJS]
|
||||
related:
|
||||
- functions/safe/CSS
|
||||
- functions/safe/HTML
|
||||
- functions/safe/HTMLAttr
|
||||
- functions/safe/JSStr
|
||||
- functions/safe/URL
|
||||
returnType: template.JS
|
||||
signatures: [safe.JS INPUT]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [safeJS]
|
||||
returnType: template.JS
|
||||
signatures: [safe.JS INPUT]
|
||||
aliases: [/functions/safejs]
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
{{% include "functions/_common/go-html-template-package.md" %}}
|
||||
{{% include "/_common/functions/go-html-template-package.md" %}}
|
||||
|
||||
## Usage
|
||||
|
||||
|
@@ -3,23 +3,17 @@ title: safe.JSStr
|
||||
description: Declares the given string as a safe JavaScript string.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [safeJSStr]
|
||||
related:
|
||||
- functions/safe/CSS
|
||||
- functions/safe/HTML
|
||||
- functions/safe/HTMLAttr
|
||||
- functions/safe/JS
|
||||
- functions/safe/URL
|
||||
returnType: template.JSStr
|
||||
signatures: [safe.JSStr INPUT]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [safeJSStr]
|
||||
returnType: template.JSStr
|
||||
signatures: [safe.JSStr INPUT]
|
||||
aliases: [/functions/safejsstr]
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
{{% include "functions/_common/go-html-template-package.md" %}}
|
||||
{{% include "/_common/functions/go-html-template-package.md" %}}
|
||||
|
||||
## Usage
|
||||
|
||||
|
@@ -3,23 +3,17 @@ title: safe.URL
|
||||
description: Declares the given string as a safe URL or URL substring.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [safeURL]
|
||||
related:
|
||||
- functions/safe/CSS
|
||||
- functions/safe/HTML
|
||||
- functions/safe/HTMLAttr
|
||||
- functions/safe/JS
|
||||
- functions/safe/JSStr
|
||||
returnType: template.URL
|
||||
signatures: [safe.URL INPUT]
|
||||
toc: true
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [safeURL]
|
||||
returnType: template.URL
|
||||
signatures: [safe.URL INPUT]
|
||||
aliases: [/functions/safeurl]
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
{{% include "functions/_common/go-html-template-package.md" %}}
|
||||
{{% include "/_common/functions/go-html-template-package.md" %}}
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -33,8 +27,6 @@ Use of this type presents a security risk: the encapsulated content should come
|
||||
|
||||
See the [Go documentation] for details.
|
||||
|
||||
[Go documentation]: https://pkg.go.dev/html/template#URL
|
||||
|
||||
## Example
|
||||
|
||||
Without a safe declaration:
|
||||
@@ -50,9 +42,8 @@ Hugo renders the above to:
|
||||
<a href="#ZgotmplZ">IRC</a>
|
||||
```
|
||||
|
||||
{{% note %}}
|
||||
`ZgotmplZ` is a special value that indicates that unsafe content reached a CSS or URL context at runtime.
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> `ZgotmplZ` is a special value that indicates that unsafe content reached a CSS or URL context at runtime.
|
||||
|
||||
To declare the string as safe:
|
||||
|
||||
@@ -66,3 +57,5 @@ Hugo renders the above to:
|
||||
```html
|
||||
<a href="irc://irc.freenode.net/#golang">IRC</a>
|
||||
```
|
||||
|
||||
[Go documentation]: https://pkg.go.dev/html/template#URL
|
||||
|
@@ -1,14 +1,7 @@
|
||||
---
|
||||
title: Safe functions
|
||||
linkTitle: safe
|
||||
description: Template functions to declare a value as safe in the context of Go's html/template package.
|
||||
description: Use these functions to declare a value as safe in the context of Go's html/template package.
|
||||
categories: []
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: functions
|
||||
---
|
||||
|
||||
Use these functions to declare a value as safe in the context of Go's [html/template] package.
|
||||
|
||||
[html/template]: https://pkg.go.dev/html/template
|
||||
|
Reference in New Issue
Block a user