diff --git a/config/_default/security.toml b/config/_default/security.toml
index 2be3f1ba8..8bd91945f 100644
--- a/config/_default/security.toml
+++ b/config/_default/security.toml
@@ -1,10 +1,6 @@
enableInlineShortcodes = false
- [exec]
- allow = ['^go$']
- osEnv = ['^PATH$']
-
[funcs]
getenv = ['^HUGO_', '^REPOSITORY_URL$', '^BRANCH$']
diff --git a/content/en/commands/hugo.md b/content/en/commands/hugo.md
index f521a2d1f..fa8f6d1ed 100644
--- a/content/en/commands/hugo.md
+++ b/content/en/commands/hugo.md
@@ -27,7 +27,7 @@ hugo [flags]
-D, --buildDrafts include content marked as draft
-E, --buildExpired include expired content
-F, --buildFuture include content with publishdate in the future
- --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
+ --cacheDir string filesystem path to cache directory
--cleanDestinationDir remove files from destination not found in static directories
--clock string set the clock used by Hugo, e.g. --clock 2021-11-06T22:30:00.00+09:00
--config string config file (default is hugo.yaml|json|toml)
diff --git a/content/en/commands/hugo_completion_bash.md b/content/en/commands/hugo_completion_bash.md
index 231804d09..875ecfc19 100644
--- a/content/en/commands/hugo_completion_bash.md
+++ b/content/en/commands/hugo_completion_bash.md
@@ -62,3 +62,4 @@ hugo completion bash
### SEE ALSO
* [hugo completion](/commands/hugo_completion/) - Generate the autocompletion script for the specified shell
+
diff --git a/content/en/commands/hugo_config.md b/content/en/commands/hugo_config.md
index e910a3235..3ec3748a3 100644
--- a/content/en/commands/hugo_config.md
+++ b/content/en/commands/hugo_config.md
@@ -19,7 +19,7 @@ hugo config [command] [flags]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
- --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
+ --cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
--format string preferred file format (toml, yaml or json) (default "toml")
-h, --help help for config
diff --git a/content/en/commands/hugo_config_mounts.md b/content/en/commands/hugo_config_mounts.md
index 59087c771..90b171912 100644
--- a/content/en/commands/hugo_config_mounts.md
+++ b/content/en/commands/hugo_config_mounts.md
@@ -15,7 +15,7 @@ hugo config mounts [flags] [args]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
- --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
+ --cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
-h, --help help for mounts
-t, --theme strings themes to use (located in /themes/THEMENAME/)
diff --git a/content/en/commands/hugo_mod_clean.md b/content/en/commands/hugo_mod_clean.md
index 6ca413993..c1c2b0c0d 100644
--- a/content/en/commands/hugo_mod_clean.md
+++ b/content/en/commands/hugo_mod_clean.md
@@ -20,7 +20,7 @@ hugo mod clean [flags] [args]
```
--all clean entire module cache
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
- --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
+ --cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
-h, --help help for clean
--pattern string pattern matching module paths to clean (all if not set), e.g. "**hugo*"
diff --git a/content/en/commands/hugo_mod_graph.md b/content/en/commands/hugo_mod_graph.md
index 55c95ca23..a2e2b51a3 100644
--- a/content/en/commands/hugo_mod_graph.md
+++ b/content/en/commands/hugo_mod_graph.md
@@ -21,7 +21,7 @@ hugo mod graph [flags] [args]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
- --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
+ --cacheDir string filesystem path to cache directory
--clean delete module cache for dependencies that fail verification
-c, --contentDir string filesystem path to content directory
-h, --help help for graph
diff --git a/content/en/commands/hugo_mod_init.md b/content/en/commands/hugo_mod_init.md
index bef38c050..49b2609e1 100644
--- a/content/en/commands/hugo_mod_init.md
+++ b/content/en/commands/hugo_mod_init.md
@@ -26,7 +26,7 @@ hugo mod init [flags] [args]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
- --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
+ --cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
-h, --help help for init
-t, --theme strings themes to use (located in /themes/THEMENAME/)
diff --git a/content/en/commands/hugo_mod_npm_pack.md b/content/en/commands/hugo_mod_npm_pack.md
index 4f37f40df..30214d556 100644
--- a/content/en/commands/hugo_mod_npm_pack.md
+++ b/content/en/commands/hugo_mod_npm_pack.md
@@ -29,7 +29,7 @@ hugo mod npm pack [flags] [args]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
- --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
+ --cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
-h, --help help for pack
-t, --theme strings themes to use (located in /themes/THEMENAME/)
diff --git a/content/en/commands/hugo_mod_tidy.md b/content/en/commands/hugo_mod_tidy.md
index b28c6a3c2..803ef1c5b 100644
--- a/content/en/commands/hugo_mod_tidy.md
+++ b/content/en/commands/hugo_mod_tidy.md
@@ -15,7 +15,7 @@ hugo mod tidy [flags] [args]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
- --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
+ --cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
-h, --help help for tidy
-t, --theme strings themes to use (located in /themes/THEMENAME/)
diff --git a/content/en/commands/hugo_mod_vendor.md b/content/en/commands/hugo_mod_vendor.md
index 3df563621..3a829d5fd 100644
--- a/content/en/commands/hugo_mod_vendor.md
+++ b/content/en/commands/hugo_mod_vendor.md
@@ -21,7 +21,7 @@ hugo mod vendor [flags] [args]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
- --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
+ --cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
-h, --help help for vendor
-t, --theme strings themes to use (located in /themes/THEMENAME/)
diff --git a/content/en/commands/hugo_mod_verify.md b/content/en/commands/hugo_mod_verify.md
index 86f908564..b647a2cbb 100644
--- a/content/en/commands/hugo_mod_verify.md
+++ b/content/en/commands/hugo_mod_verify.md
@@ -19,7 +19,7 @@ hugo mod verify [flags] [args]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
- --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
+ --cacheDir string filesystem path to cache directory
--clean delete module cache for dependencies that fail verification
-c, --contentDir string filesystem path to content directory
-h, --help help for verify
diff --git a/content/en/commands/hugo_new_content.md b/content/en/commands/hugo_new_content.md
index c7f87631c..dd646766b 100644
--- a/content/en/commands/hugo_new_content.md
+++ b/content/en/commands/hugo_new_content.md
@@ -26,7 +26,7 @@ hugo new content [path] [flags]
```
-b, --baseURL string hostname (and path) to the root, e.g. https://spf13.com/
- --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
+ --cacheDir string filesystem path to cache directory
-c, --contentDir string filesystem path to content directory
--editor string edit new content with this editor, if provided
-f, --force overwrite file if it already exists
diff --git a/content/en/commands/hugo_server.md b/content/en/commands/hugo_server.md
index 601fd4406..49cd1867b 100644
--- a/content/en/commands/hugo_server.md
+++ b/content/en/commands/hugo_server.md
@@ -33,7 +33,7 @@ hugo server [command] [flags]
-D, --buildDrafts include content marked as draft
-E, --buildExpired include expired content
-F, --buildFuture include content with publishdate in the future
- --cacheDir string filesystem path to cache directory. Defaults: $TMPDIR/hugo_cache_$USER/
+ --cacheDir string filesystem path to cache directory
--cleanDestinationDir remove files from destination not found in static directories
-c, --contentDir string filesystem path to content directory
--disableBrowserError do not show build errors in the browser
diff --git a/content/en/content-management/multilingual.md b/content/en/content-management/multilingual.md
index 4c1f6446e..849df681f 100644
--- a/content/en/content-management/multilingual.md
+++ b/content/en/content-management/multilingual.md
@@ -506,7 +506,7 @@ See [lang.FormatNumber] and [lang.FormatNumberCustom] for details.
With this template code:
```go-html-template
-{{ 512.5032 | lang.FormatPercent 2 }} ---> 512.50%
+{{ 512.5032 | lang.FormatPercent 2 }} → 512.50%
```
The rendered page displays:
diff --git a/content/en/content-management/summaries.md b/content/en/content-management/summaries.md
index 4f94f95f2..74c5623cb 100644
--- a/content/en/content-management/summaries.md
+++ b/content/en/content-management/summaries.md
@@ -85,19 +85,19 @@ You can show content summaries with the following code. You could use the follow
{{< code file="page-list-with-summaries.html" >}}
{{ range first 10 .Pages }}
- {{ .Title }}
- {{ .Summary }}
- {{ .Title }}
+ {{ .Summary }}
+ {{ .Title }}
-
{{ .Description }}
{{ end }} diff --git a/content/en/functions/anchorize.md b/content/en/functions/anchorize.md index bdf322a6e..51ef67bb2 100644 --- a/content/en/functions/anchorize.md +++ b/content/en/functions/anchorize.md @@ -15,10 +15,10 @@ If [Goldmark](/getting-started/configuration-markup#goldmark) is set as `default Since the `defaultMarkdownHandler` and this template function use the same sanitizing logic, you can use the latter to determine the ID of a header for linking with anchor tags. ```go-html-template -{{ anchorize "This is a header" }} --> "this-is-a-header" -{{ anchorize "This is also a header" }} --> "this-is-also----a-header" -{{ anchorize "main.go" }} --> "maingo" -{{ anchorize "Article 123" }} --> "article-123" -{{ anchorize "<- Let's try this, shall we?" }} --> "--lets-try-this-shall-we" -{{ anchorize "Hello, 世界" }} --> "hello-世界" +{{ anchorize "This is a header" }} → "this-is-a-header" +{{ anchorize "This is also a header" }} → "this-is-also----a-header" +{{ anchorize "main.go" }} → "maingo" +{{ anchorize "Article 123" }} → "article-123" +{{ anchorize "<- Let's try this, shall we?" }} → "--lets-try-this-shall-we" +{{ anchorize "Hello, 世界" }} → "hello-世界" ``` diff --git a/content/en/functions/append.md b/content/en/functions/append.md index 626bc1242..6d7ffa245 100644 --- a/content/en/functions/append.md +++ b/content/en/functions/append.md @@ -26,4 +26,12 @@ The same example appending a slice to a slice: {{ $s = $s | append (slice "d" "e") }} ``` +If a slice contains other slices, further slices will be appended as values: + +```go-html-template +{{ $s := slice (slice "a" "b") (slice "c" "d") }} +{{ $s = $s | append (slice "e" "f") (slice "g" "h") }} +{{/* $s now contains a [][]string containing four slices: ["a" "b"], ["c" "d"], ["e" "f"], and ["g" "h"] */}} +``` + The `append` function works for all types, including `Pages`. diff --git a/content/en/functions/common/index.md b/content/en/functions/common/index.md new file mode 100644 index 000000000..cbb7365a6 --- /dev/null +++ b/content/en/functions/common/index.md @@ -0,0 +1,3 @@ ++++ +headless = true ++++ diff --git a/content/en/functions/common/regular-expressions.md b/content/en/functions/common/regular-expressions.md new file mode 100644 index 000000000..9da340849 --- /dev/null +++ b/content/en/functions/common/regular-expressions.md @@ -0,0 +1,8 @@ +When specifying the regular expression, use a raw [string literal] (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes. + +Go's regular expression package implements the [RE2 syntax]. The RE2 syntax is a subset of that accepted by [PCRE], roughly speaking, and with various [caveats]. Note that the RE2 `\C` escape sequence is not supported. + +[caveats]: https://swtch.com/~rsc/regexp/regexp3.html#caveats +[PCRE]: https://www.pcre.org/ +[RE2 syntax]: https://github.com/google/re2/wiki/Syntax/ +[string literal]: https://go.dev/ref/spec#String_literals diff --git a/content/en/functions/fileExists.md b/content/en/functions/fileExists.md index 5a365b7c1..f7b5c37e0 100644 --- a/content/en/functions/fileExists.md +++ b/content/en/functions/fileExists.md @@ -24,11 +24,11 @@ content/ The function returns these values: ```go-html-template -{{ os.FileExists "content" }} --> true -{{ os.FileExists "content/news" }} --> true -{{ os.FileExists "content/news/article-1" }} --> false -{{ os.FileExists "content/news/article-1.md" }} --> true -{{ os.FileExists "news" }} --> true -{{ os.FileExists "news/article-1" }} --> false -{{ os.FileExists "news/article-1.md" }} --> true +{{ os.FileExists "content" }} → true +{{ os.FileExists "content/news" }} → true +{{ os.FileExists "content/news/article-1" }} → false +{{ os.FileExists "content/news/article-1.md" }} → true +{{ os.FileExists "news" }} → true +{{ os.FileExists "news/article-1" }} → false +{{ os.FileExists "news/article-1.md" }} → true ``` diff --git a/content/en/functions/findRe.md b/content/en/functions/findRe.md index 0b8978ec6..3c977118c 100644 --- a/content/en/functions/findRe.md +++ b/content/en/functions/findRe.md @@ -13,21 +13,7 @@ relatedfuncs: [findRESubmatch, replaceRE] --- By default, `findRE` finds all matches. You can limit the number of matches with an optional LIMIT parameter. -When specifying the regular expression, use a raw [string literal] (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes. - -[string literal]: https://go.dev/ref/spec#String_literals - -This function uses the [RE2] regular expression library. See the [RE2 syntax documentation] for details. Note that the RE2 `\C` escape sequence is not supported. - -[RE2]: https://github.com/google/re2/ -[RE2 syntax documentation]: https://github.com/google/re2/wiki/Syntax/ - -{{% note %}} -The RE2 syntax is a subset of that accepted by [PCRE], roughly speaking, and with various [caveats]. - -[caveats]: https://swtch.com/~rsc/regexp/regexp3.html#caveats -[PCRE]: https://www.pcre.org/ -{{% /note %}} +{{% readfile file="/functions/common/regular-expressions.md" %}} This example returns a slice of all second level headings (`h2` elements) within the rendered `.Content`: diff --git a/content/en/functions/findresubmatch.md b/content/en/functions/findresubmatch.md index e1085a9c9..1f0f26b49 100644 --- a/content/en/functions/findresubmatch.md +++ b/content/en/functions/findresubmatch.md @@ -14,21 +14,7 @@ relatedfuncs: [findRE, replaceRE] By default, `findRESubmatch` finds all matches. You can limit the number of matches with an optional LIMIT parameter. A return value of nil indicates no match. -When specifying the regular expression, use a raw [string literal] (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes. - -[string literal]: https://go.dev/ref/spec#String_literals - -This function uses the [RE2] regular expression library. See the [RE2 syntax documentation] for details. Note that the RE2 `\C` escape sequence is not supported. - -[RE2]: https://github.com/google/re2/ -[RE2 syntax documentation]: https://github.com/google/re2/wiki/Syntax/ - -{{% note %}} -The RE2 syntax is a subset of that accepted by [PCRE], roughly speaking, and with various [caveats]. - -[caveats]: https://swtch.com/~rsc/regexp/regexp3.html#caveats -[PCRE]: https://www.pcre.org/ -{{% /note %}} +{{% readfile file="/functions/common/regular-expressions.md" %}} ## Demonstrative examples diff --git a/content/en/functions/getenv.md b/content/en/functions/getenv.md index e014b7ad5..daeeb6532 100644 --- a/content/en/functions/getenv.md +++ b/content/en/functions/getenv.md @@ -12,8 +12,8 @@ relatedfuncs: [] Examples: ```go-html-template -{{ os.Getenv "HOME" }} --> /home/victor -{{ os.Getenv "USER" }} --> victor +{{ os.Getenv "HOME" }} → /home/victor +{{ os.Getenv "USER" }} → victor ``` You can pass values when building your site: @@ -31,8 +31,8 @@ hugo And then retrieve the values within a template: ```go-html-template -{{ os.Getenv "MY_VAR1" }} --> foo -{{ os.Getenv "MY_VAR2" }} --> bar +{{ os.Getenv "MY_VAR1" }} → foo +{{ os.Getenv "MY_VAR2" }} → bar ``` With Hugo v0.91.0 and later, you must explicitly allow access to environment variables. For details, review [Hugo's Security Policy](/about/security-model/#security-policy). By default, environment variables beginning with `HUGO_` are allowed when using the `os.Getenv` function. diff --git a/content/en/functions/hasPrefix.md b/content/en/functions/hasPrefix.md deleted file mode 100644 index 264044577..000000000 --- a/content/en/functions/hasPrefix.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: hasprefix -description: Tests whether a string begins with prefix. -date: 2017-02-01 -publishdate: 2017-02-01 -lastmod: 2017-02-01 -categories: [functions] -menu: - docs: - parent: "functions" -keywords: [strings] -signature: ["hasPrefix STRING PREFIX"] -workson: [] -hugoversion: -relatedfuncs: [hasSuffix] -deprecated: false -aliases: [] ---- - -* `{{ hasPrefix "Hugo" "Hu" }}` → true diff --git a/content/en/functions/hasSuffix.md b/content/en/functions/hasSuffix.md deleted file mode 100644 index 5ab38866d..000000000 --- a/content/en/functions/hasSuffix.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -title: hassuffix -linkTitle: hasSuffix -description: Tests whether a string ends with suffix. -date: 2023-03-01 -publishdate: 2023-03-01 -lastmod: 2023-03-01 -categories: [functions] -menu: -docs: -parent: "functions" -keywords: [strings] -signature: ["hasSuffix STRING SUFFIX"] -workson: [] -hugoversion: -relatedfuncs: [hasPrefix] -deprecated: false -aliases: [] ---- - -* `{{ hasSuffix "Hugo" "go" }}` → true diff --git a/content/en/functions/merge.md b/content/en/functions/merge.md index 68e561450..ed370549e 100644 --- a/content/en/functions/merge.md +++ b/content/en/functions/merge.md @@ -27,9 +27,9 @@ Example 1 ```go-html-template {{ $merged := merge $m1 $m2 $m3 }} -{{ $merged.x }} --> baz -{{ $merged.y }} --> wobble -{{ $merged.z.a }} --> huey +{{ $merged.x }} → baz +{{ $merged.y }} → wobble +{{ $merged.z.a }} → huey ``` Example 2 @@ -37,9 +37,9 @@ Example 2 ```go-html-template {{ $merged := merge $m3 $m2 $m1 }} -{{ $merged.x }} --> foo -{{ $merged.y }} --> wibble -{{ $merged.z.a }} --> huey +{{ $merged.x }} → foo +{{ $merged.y }} → wibble +{{ $merged.z.a }} → huey ``` Example 3 @@ -47,9 +47,9 @@ Example 3 ```go-html-template {{ $merged := merge $m2 $m3 $m1 }} -{{ $merged.x }} --> foo -{{ $merged.y }} --> wobble -{{ $merged.z.a }} --> huey +{{ $merged.x }} → foo +{{ $merged.y }} → wobble +{{ $merged.z.a }} → huey ``` Example 4 @@ -57,9 +57,9 @@ Example 4 ```go-html-template {{ $merged := merge $m1 $m3 $m2 }} -{{ $merged.x }} --> bar -{{ $merged.y }} --> wibble -{{ $merged.z.a }} --> huey +{{ $merged.x }} → bar +{{ $merged.y }} → wibble +{{ $merged.z.a }} → huey ``` {{% note %}} diff --git a/content/en/functions/os.Stat.md b/content/en/functions/os.Stat.md index 9ace3b8bf..51d35ae2f 100644 --- a/content/en/functions/os.Stat.md +++ b/content/en/functions/os.Stat.md @@ -13,13 +13,13 @@ The `os.Stat` function attempts to resolve the path relative to the root of your ```go-html-template {{ $f := os.Stat "README.md" }} -{{ $f.IsDir }} --> false (bool) -{{ $f.ModTime }} --> 2021-11-25 10:06:49.315429236 -0800 PST (time.Time) -{{ $f.Name }} --> README.md (string) -{{ $f.Size }} --> 241 (int64) +{{ $f.IsDir }} → false (bool) +{{ $f.ModTime }} → 2021-11-25 10:06:49.315429236 -0800 PST (time.Time) +{{ $f.Name }} → README.md (string) +{{ $f.Size }} → 241 (int64) {{ $d := os.Stat "content" }} -{{ $d.IsDir }} --> true (bool) +{{ $d.IsDir }} → true (bool) ``` Details of the `FileInfo` structure are available in the [Go documentation](https://pkg.go.dev/io/fs#FileInfo). diff --git a/content/en/functions/readdir.md b/content/en/functions/readdir.md index 9fc4d3013..a76e3c5f6 100644 --- a/content/en/functions/readdir.md +++ b/content/en/functions/readdir.md @@ -26,7 +26,7 @@ This template code: ```go-html-template {{ range os.ReadDir "content" }} - {{ .Name }} --> {{ .IsDir }} + {{ .Name }} → {{ .IsDir }} {{ end }} ``` diff --git a/content/en/functions/replacere.md b/content/en/functions/replacere.md index 22f81a2f5..8c3cc13c2 100644 --- a/content/en/functions/replacere.md +++ b/content/en/functions/replacere.md @@ -13,21 +13,7 @@ relatedfuncs: [findRE, FindRESubmatch, replace] --- By default, `replaceRE` replaces all matches. You can limit the number of matches with an optional LIMIT parameter. -When specifying the regular expression, use a raw [string literal] (backticks) instead of an interpreted string literal (double quotes) to simplify the syntax. With an interpreted string literal you must escape backslashes. - -[string literal]: https://go.dev/ref/spec#String_literals - -This function uses the [RE2] regular expression library. See the [RE2 syntax documentation] for details. Note that the RE2 `\C` escape sequence is not supported. - -[RE2]: https://github.com/google/re2/ -[RE2 syntax documentation]: https://github.com/google/re2/wiki/Syntax/ - -{{% note %}} -The RE2 syntax is a subset of that accepted by [PCRE], roughly speaking, and with various [caveats]. - -[caveats]: https://swtch.com/~rsc/regexp/regexp3.html#caveats -[PCRE]: https://www.pcre.org/ -{{% /note %}} +{{% readfile file="/functions/common/regular-expressions.md" %}} This example replaces two or more consecutive hyphens with a single hyphen: diff --git a/content/en/functions/scratch.md b/content/en/functions/scratch.md index 2e00f41bd..16e502b84 100644 --- a/content/en/functions/scratch.md +++ b/content/en/functions/scratch.md @@ -72,7 +72,7 @@ Get the value of a given key. Add a given value to existing value(s) of the given key. -For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be appended to that list. +For single values, `Add` accepts values that support Go's `+` operator. If the first `Add` for a key is an array or slice, the following adds will be [appended](/functions/append/) to that list. ```go-html-template {{ $scratch.Add "greetings" "Hello" }} diff --git a/content/en/functions/strings.ContainsNonSpace.md b/content/en/functions/strings.ContainsNonSpace.md new file mode 100644 index 000000000..eafe292f5 --- /dev/null +++ b/content/en/functions/strings.ContainsNonSpace.md @@ -0,0 +1,27 @@ +--- +title: strings.ContainsNonSpace +description: Reports whether a string contains any non-space characters as defined by Unicode’s White Space property. +categories: [functions] +menu: + docs: + parent: functions +keywords: [whitespace space] +signature: ["strings.ContainsNonSpace STRING"] +relatedfuncs: ["strings.Contains","strings.ContainsAny"] +--- + +```go-html-template +{{ strings.ContainsNonSpace "\n" }} → false +{{ strings.ContainsNonSpace " " }} → false +{{ strings.ContainsNonSpace "\n abc" }} → true +``` + +Common white space characters include: + +```text +'\t', '\n', '\v', '\f', '\r', ' ' +``` + +See the [Unicode Character Database] for a complete list. + +[Unicode Character Database]: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt diff --git a/content/en/functions/transform.Unmarshal.md b/content/en/functions/transform.Unmarshal.md index ca5433761..7d0920da8 100644 --- a/content/en/functions/transform.Unmarshal.md +++ b/content/en/functions/transform.Unmarshal.md @@ -62,12 +62,12 @@ The following example lists the items of an RSS feed: ```go-html-template {{ with resources.GetRemote "https://example.com/rss.xml" | transform.Unmarshal }} - {{ range .channel.item }} - {{ .title | plainify | htmlUnescape }}{{ .description | plainify | htmlUnescape }}
- {{ $link := .link | plainify | htmlUnescape }} - {{ $link }}{{ .description | plainify | htmlUnescape }}
+ {{ $link := .link | plainify | htmlUnescape }} + {{ $link }}{{ .Title }}
{{ end }} ``` - ## Use `where` with `intersect` @@ -102,6 +104,18 @@ You can also put the returned value of the `where` clauses into a variable: {{ end }} {{< /code >}} +## Use `where` with `like` + +This example matches pages where the "foo" parameter begins with "ab": + +```go-html-template +{{ range where site.RegularPages "Params.foo" "like" `^ab` }} +