diff --git a/content/en/functions/after.md b/content/en/functions/after.md index df2142ab6..9a2a68c5f 100644 --- a/content/en/functions/after.md +++ b/content/en/functions/after.md @@ -19,7 +19,7 @@ aliases: [] The following shows `after` being used in conjunction with the [`slice` function][slice]: -``` +```go-html-template {{ $data := slice "one" "two" "three" "four" }} {{ range after 2 $data }} {{ . }} diff --git a/content/en/functions/apply.md b/content/en/functions/apply.md index 4c36cf17e..0f02c1b4c 100644 --- a/content/en/functions/apply.md +++ b/content/en/functions/apply.md @@ -37,7 +37,7 @@ names: [ "Derek Perkins", "Joe Bergevin", "Tanner Linsley" ] You can then use `apply` as follows: -``` +```go-html-template {{ apply .Params.names "urlize" "." }} ``` @@ -49,7 +49,7 @@ Which will result in the following: This is *roughly* equivalent to using the following with [range]: -``` +```go-html-template {{ range .Params.names }}{{ . | urlize }}{{ end }} ``` @@ -83,7 +83,7 @@ This works, but the complexity of `post-tag-list.html` is fairly high. The Hugo This first version of `layouts/partials/post-tag-list.html` separates all of the operations for ease of reading. The combined and DRYer version is shown next: -``` +```go-html-template {{ with .Params.tags }}
Blockhead
\n"}} → "Blockhead
" ``` diff --git a/content/en/functions/cond.md b/content/en/functions/cond.md index 30b853251..b7b5e3d55 100644 --- a/content/en/functions/cond.md +++ b/content/en/functions/cond.md @@ -17,7 +17,7 @@ draft: false Example: -``` +```go-html-template {{ cond (eq (len $geese) 1) "goose" "geese" }} ``` diff --git a/content/en/functions/countrunes.md b/content/en/functions/countrunes.md index 01ded4d6f..e3add0d7f 100644 --- a/content/en/functions/countrunes.md +++ b/content/en/functions/countrunes.md @@ -20,7 +20,7 @@ deprecated: false In contrast with `countwords` function, which counts every word in a string, the `countrunes` function determines the number of runes in the content and excludes any whitespace. This has specific utility if you are dealing with CJK-like languages. -``` +```go-html-template {{ "Hello, 世界" | countrunes }} ``` diff --git a/content/en/functions/countwords.md b/content/en/functions/countwords.md index 17f0fa5c2..c0ca72aa3 100644 --- a/content/en/functions/countwords.md +++ b/content/en/functions/countwords.md @@ -18,7 +18,7 @@ deprecated: false The template function works similar to the [.WordCount page variable][pagevars]. -``` +```go-html-template {{ "Hugo is a static site generator." | countwords }} ``` diff --git a/content/en/functions/default.md b/content/en/functions/default.md index defdad480..b187331de 100644 --- a/content/en/functions/default.md +++ b/content/en/functions/default.md @@ -42,7 +42,7 @@ newparam: `default` can be written in more than one way: -``` +```go-html-template {{ index .Params "font" | default "Roboto" }} {{ default "Roboto" (index .Params "font") }} ``` @@ -58,7 +58,7 @@ A `default` value, however, does not need to be hard coded like the previous exa Which would return: -``` +```htmlThe default function helps make your templating DRYer.
``` diff --git a/content/en/functions/delimit.md b/content/en/functions/delimit.md index 4705a7f2d..63207b268 100644 --- a/content/en/functions/delimit.md +++ b/content/en/functions/delimit.md @@ -21,7 +21,7 @@ aliases: [] `delimit` called in your template takes the form of -``` +```go-html-template {{ delimit array/slice/map delimiter optionallastdelimiter }} ``` diff --git a/content/en/functions/echoparam.md b/content/en/functions/echoparam.md index 515b5c449..abdd0072a 100644 --- a/content/en/functions/echoparam.md +++ b/content/en/functions/echoparam.md @@ -19,6 +19,6 @@ aliases: [] --- -``` +```go-html-template {{ echoParam .Params "project_url" }} ``` diff --git a/content/en/functions/eq.md b/content/en/functions/eq.md index d342a628a..47901f16e 100644 --- a/content/en/functions/eq.md +++ b/content/en/functions/eq.md @@ -19,6 +19,6 @@ aliases: [] --- -``` +```go-html-template {{ if eq .Section "blog" }}current{{ end }} ``` diff --git a/content/en/functions/errorf.md b/content/en/functions/errorf.md index 04fd0edb0..4e5160b25 100644 --- a/content/en/functions/errorf.md +++ b/content/en/functions/errorf.md @@ -22,11 +22,11 @@ Any ERROR will also cause the build to fail (the `hugo` command will `exit -1`). Both functions return an empty string, so the messages are only printed to the console. -``` +```go-html-template {{ errorf "Failed to handle page %q" .Path }} ``` -``` +```go-html-template {{ warnf "You should update the shortcodes in %q" .Path }} ``` @@ -38,7 +38,7 @@ Sometimes it may make sense to let the user suppress an ERROR and make the build You can do this by using the `erroridf` function. This functions takes an error ID as the first argument. -``` +```go-html-template {{ erroridf "my-custom-error" "You should consider fixing this." }} ``` diff --git a/content/en/functions/format.md b/content/en/functions/format.md index 5c86714fe..201a779cd 100644 --- a/content/en/functions/format.md +++ b/content/en/functions/format.md @@ -97,7 +97,7 @@ Spelled-out cardinal numbers (e.g. "one", "two", and "three") are not currently Use the [`humanize`](/functions/humanize) function to render the day of the month as an ordinal number: -``` +```go-html-template {{ humanize .Date.Day }} of {{ .Date.Format "January 2006" }} ``` diff --git a/content/en/functions/ge.md b/content/en/functions/ge.md index c7256c0e3..915930528 100644 --- a/content/en/functions/ge.md +++ b/content/en/functions/ge.md @@ -19,6 +19,6 @@ aliases: [] --- -``` +```go-html-template {{ if ge 10 5 }}true{{ end }} ``` diff --git a/content/en/functions/gt.md b/content/en/functions/gt.md index 91203f890..9643ee36d 100644 --- a/content/en/functions/gt.md +++ b/content/en/functions/gt.md @@ -19,6 +19,6 @@ aliases: [] --- -``` +```go-html-template {{ if gt 10 5 }}true{{ end }} ``` diff --git a/content/en/functions/i18n.md b/content/en/functions/i18n.md index 8f8c9642c..1dbbfcb76 100644 --- a/content/en/functions/i18n.md +++ b/content/en/functions/i18n.md @@ -23,7 +23,7 @@ aliases: [] 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. -``` +```go-html-template {{ i18n "translation_id" }} ``` @@ -35,7 +35,7 @@ This translates a piece of content based on your `i18n/en-US.toml` files. You ca Often you will want to use the page variables in the translation strings. To do so, pass the `.` context when calling `i18n`: -``` +```go-html-template {{ i18n "wordCount" . }} ``` diff --git a/content/en/functions/in.md b/content/en/functions/in.md index 7a8cb33eb..c1ef45629 100644 --- a/content/en/functions/in.md +++ b/content/en/functions/in.md @@ -22,11 +22,11 @@ The elements supported are strings, integers and floats, although only float64 w In addition, `in` can also check if a substring exists in a string. -``` +```go-html-template {{ if in .Params.tags "Git" }}Follow me on GitHub!{{ end }} ``` -``` +```go-html-template {{ if in "this string contains a substring" "substring" }}Substring found!{{ end }} ``` diff --git a/content/en/functions/index-function.md b/content/en/functions/index-function.md index 6ee46b4a8..970ee0c49 100644 --- a/content/en/functions/index-function.md +++ b/content/en/functions/index-function.md @@ -69,7 +69,7 @@ pop_metro = 1717900 The example we will use will be an article on Oslo, whose front matter should be set to exactly the same name as the corresponding file name in `data/locations/`: -``` +```toml title = "My Norwegian Vacation" location = "oslo" ``` @@ -81,8 +81,8 @@ This is where the `index` function is needed. `index` takes 2 parameters in this 1. The node path 2. A string corresponding to the desired data; e.g.— -``` -{{ index .Site.Data.locations “oslo” }} +```go-html-template +{{ index .Site.Data.locations "oslo" }} ``` The variable for `.Params.location` is a string and can therefore replace `oslo` in the example above: diff --git a/content/en/functions/int.md b/content/en/functions/int.md index 309368702..74a22714b 100644 --- a/content/en/functions/int.md +++ b/content/en/functions/int.md @@ -32,7 +32,7 @@ number representation. The `strings.TrimLeft` can be used for this purpose. -``` +```go-html-template {{ int ("0987" | strings.TrimLeft "0") }} {{ int ("00987" | strings.TrimLeft "0") }} ``` diff --git a/content/en/functions/intersect.md b/content/en/functions/intersect.md index 8d4c50fe2..4a645234f 100644 --- a/content/en/functions/intersect.md +++ b/content/en/functions/intersect.md @@ -21,7 +21,7 @@ A useful example is to use it as `AND` filters when combined with where: ## AND filter in where query -``` +```go-html-template {{ $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) }} diff --git a/content/en/functions/isset.md b/content/en/functions/isset.md index 2bfc43203..2be8a1587 100644 --- a/content/en/functions/isset.md +++ b/content/en/functions/isset.md @@ -20,7 +20,7 @@ aliases: [] Takes either a slice, array, or channel and an index or a map and a key as input. -``` +```go-html-template {{ if isset .Params "project_url" }} {{ index .Params "project_url" }}{{ end }} ``` diff --git a/content/en/functions/jsonify.md b/content/en/functions/jsonify.md index 72ec4634b..ecb5264ee 100644 --- a/content/en/functions/jsonify.md +++ b/content/en/functions/jsonify.md @@ -26,7 +26,7 @@ the output will begin on a new line beginning with *prefix* followed by one or more copies of *indent* according to the indentation nesting. -``` +```go-html-template {{ dict "title" .Title "content" .Plain | jsonify }} {{ dict "title" .Title "content" .Plain | jsonify (dict "indent" " ") }} {{ dict "title" .Title "content" .Plain | jsonify (dict "prefix" " " "indent" " ") }} diff --git a/content/en/functions/last.md b/content/en/functions/last.md index 4a752cb82..63fdfa129 100644 --- a/content/en/functions/last.md +++ b/content/en/functions/last.md @@ -20,7 +20,7 @@ draft: false aliases: [] --- -``` +```go-html-template {{ range last 10 .Pages }} {{ .Render "summary" }} {{ end }} diff --git a/content/en/functions/le.md b/content/en/functions/le.md index 1ff0ac582..8df2f2479 100644 --- a/content/en/functions/le.md +++ b/content/en/functions/le.md @@ -19,6 +19,6 @@ aliases: [] --- -``` +```go-html-template {{ if le 5 10 }}true{{ end }} ``` diff --git a/content/en/functions/lt.md b/content/en/functions/lt.md index d2a234986..1e82270c3 100644 --- a/content/en/functions/lt.md +++ b/content/en/functions/lt.md @@ -19,6 +19,6 @@ aliases: [] --- -``` +```go-html-template {{ if lt 5 10 }}true{{ end }} ``` diff --git a/content/en/functions/markdownify.md b/content/en/functions/markdownify.md index d222a8eb6..44e4c9af6 100644 --- a/content/en/functions/markdownify.md +++ b/content/en/functions/markdownify.md @@ -15,7 +15,7 @@ deprecated: false aliases: [] --- -``` +```go-html-template {{ .Title | markdownify }} ``` diff --git a/content/en/functions/md5.md b/content/en/functions/md5.md index 2168034c4..0c9cabbdc 100644 --- a/content/en/functions/md5.md +++ b/content/en/functions/md5.md @@ -18,7 +18,7 @@ deprecated: false aliases: [] --- -``` +```go-html-template {{ md5 "Hello world, gophers!" }} ``` diff --git a/content/en/functions/ne.md b/content/en/functions/ne.md index e072993d2..e0fc93bbd 100644 --- a/content/en/functions/ne.md +++ b/content/en/functions/ne.md @@ -19,6 +19,6 @@ aliases: [] --- -``` +```go-html-template {{ if ne .Section "blog" }}current{{ end }} ``` diff --git a/content/en/functions/now.md b/content/en/functions/now.md index 24e1ab3f7..e54f952e8 100644 --- a/content/en/functions/now.md +++ b/content/en/functions/now.md @@ -22,7 +22,7 @@ See [`time.Time`](https://godoc.org/time#Time). For example, building your site on June 24, 2017, with the following templating: -``` +```go-html-template