mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 02:16:09 +00:00
Minor edits to the apply documentation
- Fix typos - Add full stop and colons - Use expanded "is not" instead of isn't (recommended in documentation)
This commit is contained in:
1 parent
04bbff8b36
commit
6c7687c2d2
1 file changed
+6
-6
@@ -10,7 +10,7 @@ menu:
|
|||||||
docs:
|
docs:
|
||||||
parent: "functions"
|
parent: "functions"
|
||||||
keywords: [advanced]
|
keywords: [advanced]
|
||||||
signature: ["apply COLLETION FUNCTION [PARAM...]"]
|
signature: ["apply COLLECTION FUNCTION [PARAM...]"]
|
||||||
workson: []
|
workson: []
|
||||||
hugoversion:
|
hugoversion:
|
||||||
relatedfuncs: []
|
relatedfuncs: []
|
||||||
@@ -25,11 +25,11 @@ POTENTIAL NEW CONTENT: see apply/sequence discussion: https://discourse.gohugo.i
|
|||||||
|
|
||||||
`apply` expects at least three parameters, depending on the function being applied.
|
`apply` expects at least three parameters, depending on the function being applied.
|
||||||
|
|
||||||
1. The first parameter is the sequence to operate on
|
1. The first parameter is the sequence to operate on.
|
||||||
2. The second parameter is the name of the function as a string, which must be the name of a valid [Hugo function][functions].
|
2. The second parameter is the name of the function as a string, which must be the name of a valid [Hugo function][functions].
|
||||||
3. After that, the parameters to the applied function are provided, with the string `"."` standing in for each element of the sequence the function is to be applied against.
|
3. After that, the parameters to the applied function are provided, with the string `"."` standing in for each element of the sequence the function is to be applied against.
|
||||||
|
|
||||||
Here is an example of a content file with `name:` as a front matter field:
|
Here is an example of a content file with `names:` as a front matter field:
|
||||||
|
|
||||||
```
|
```
|
||||||
+++
|
+++
|
||||||
@@ -43,19 +43,19 @@ You can then use `apply` as follows:
|
|||||||
{{ apply .Params.names "urlize" "." }}
|
{{ apply .Params.names "urlize" "." }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Which will result as follows:
|
Which will result in the following:
|
||||||
|
|
||||||
```
|
```
|
||||||
"derek-perkins", "joe-bergevin", "tanner-linsley"
|
"derek-perkins", "joe-bergevin", "tanner-linsley"
|
||||||
```
|
```
|
||||||
|
|
||||||
This is *roughly* equivalent to using the following with [range][]
|
This is *roughly* equivalent to using the following with [range][]:
|
||||||
|
|
||||||
```
|
```
|
||||||
{{ range .Params.names }}{{ . | urlize }}{{ end }}
|
{{ range .Params.names }}{{ . | urlize }}{{ end }}
|
||||||
```
|
```
|
||||||
|
|
||||||
However, it isn’t possible to provide the output of a range to the [`delimit` function][delimit], so you need to `apply` it.
|
However, it is not possible to provide the output of a range to the [`delimit` function][delimit], so you need to `apply` it.
|
||||||
|
|
||||||
If you have `post-tag-list.html` and `post-tag-link.html` as [partials][], you *could* use the following snippets, respectively:
|
If you have `post-tag-list.html` and `post-tag-link.html` as [partials][], you *could* use the following snippets, respectively:
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user