This commit is contained in:
Bjørn Erik Pedersen 2022-09-13 20:34:24 +02:00
commit af23cdca9c
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
45 changed files with 366 additions and 156 deletions

View file

@ -14,8 +14,6 @@ signature: [".RenderString MARKUP"]
`.RenderString` is a method on `Page` that renders some markup to HTML using the content renderer defined for that page (if not set in the options).
*Note* that this method does not parse and render shortcodes.
The method takes an optional map argument with these options:
display ("inline")

View file

@ -18,7 +18,7 @@ deprecated: false
aliases: []
---
This translates a piece of content based on your `i18n/en-US.yaml` (and similar) files. You can use the [go-i18n](https://github.com/nicksnyder/go-i18n) tools to manage your translations. The translations can exist in both the theme and at the root of your repository.
This translates a piece of content based on your `i18n/en-US.toml` files. You can use the [go-i18n](https://github.com/nicksnyder/go-i18n) tools to manage your translations. The translations can exist in both the theme and at the root of your repository.
```
{{ i18n "translation_id" }}
@ -28,6 +28,27 @@ This translates a piece of content based on your `i18n/en-US.yaml` (and similar)
`T` is an alias to `i18n`. E.g. `{{ T "translation_id" }}`.
{{% /note %}}
### Query a flexible translation with variables
Often you will want to use the page variables in the translation strings. To do so, pass the `.` context when calling `i18n`:
```
{{ i18n "wordCount" . }}
```
The function will pass the `.` context to the `"wordCount"` id:
{{< code-toggle file="i18n/en-US" >}}
[wordCount]
other = "This article has {{ .WordCount }} words."
{{< /code-toggle >}}
Assume `.WordCount` in the context has value is 101. The result will be:
```
This article has 101 words.
```
For more information about string translations, see [Translation of Strings in Multilingual Mode][multistrings].
[multistrings]: /content-management/multilingual/#translation-of-strings

View file

@ -218,6 +218,8 @@ Also see the [Filter Method](/content-management/image-processing/#filter).
Parses the image and returns the height, width, and color model.
The `imageConfig` function takes a single parameter, a file path (_string_) relative to the _project's root directory_, with or without a leading slash.
{{% funcsig %}}
images.ImageConfig PATH
{{% /funcsig %}}

View file

@ -23,7 +23,9 @@ toc: false
One use case is the concatenation of elements in combination with the [`delimit` function][]:
{{< code file="slice.html" >}}
{{ delimit (slice "foo" "bar" "buzz") ", " }}
{{ $sliceOfStrings := slice "foo" "bar" "buzz" }}
<!-- returns the slice [ "foo", "bar", "buzz"] -->
{{ delimit ($sliceOfStrings) ", " }}
<!-- returns the string "foo, bar, buzz" -->
{{< /code >}}

View file

@ -40,8 +40,8 @@ This is also very useful to use as `OR` filters when combined with where:
```
{{ $pages := where .Site.RegularPages "Type" "not in" (slice "page" "about") }}
{{ $pages := $pages | union (where .Site.RegularPages "Params.pinned" true) }}
{{ $pages := $pages | intersect (where .Site.RegularPages "Params.images" "!=" nil) }}
{{ $pages = $pages | union (where .Site.RegularPages "Params.pinned" true) }}
{{ $pages = $pages | intersect (where .Site.RegularPages "Params.images" "!=" nil) }}
```
The above fetches regular pages not of `page` or `about` type unless they are pinned. And finally, we exclude all pages with no `images` set in Page params.