diff --git a/content/contribute/themes.md b/content/contribute/themes.md index e26728d6a..d4badc045 100644 --- a/content/contribute/themes.md +++ b/content/contribute/themes.md @@ -48,7 +48,7 @@ In order to add your theme to the Hugo Themes Showcase, the following requiremen 1. `theme.toml` with all required fields 2. Images for thumbnail and screenshot 3. A good README file instructions for users -4. Added to the hugoThemes GitHub repository +4. Addition to the hugoThemes GitHub repository ### Add Your Theme to the Repo diff --git a/content/functions/scratch.md b/content/functions/scratch.md index 590c4cac5..6594c6619 100644 --- a/content/functions/scratch.md +++ b/content/functions/scratch.md @@ -66,7 +66,9 @@ The usage is best illustrated with some samples: {{ $.Scratch.GetSortedMapValues "a3" }} {{/* => []interface {}{"AA", "BB", "CC"} */}} ``` -**Note:** The examples above uses the special `$` variable, which refers to the top-level node. This is the behavior you most likely want, and will help remove some confusion when using `Scratch` inside page range loops -- and you start inadvertently calling the wrong `Scratch`. But there may be use cases for `{{ .Scratch.Add "key" "some value" }}`. +{{% note %}} +The examples above uses the special `$` variable, which refers to the top-level node. This is the behavior you most likely want, and will help remove some confusion when using `Scratch` inside page range loops -- and you start inadvertently calling the wrong `Scratch`. But there may be use cases for `{{ .Scratch.Add "key" "some value" }}`. +{{% /note %}} [pagevars]: /variables/page/ diff --git a/content/functions/trim.md b/content/functions/trim.md index 937f15683..44d7fd7d1 100644 --- a/content/functions/trim.md +++ b/content/functions/trim.md @@ -9,7 +9,7 @@ lastmod: 2017-02-01 categories: [functions] tags: [strings] ns: -signature: ["trim INPUT CUTLIST"] +signature: ["trim INPUT CUTSET"] workson: [] hugoversion: relatedfuncs: [] @@ -21,3 +21,17 @@ deprecated: false ``` {{ trim "++Batman--" "+-" }} → "Batman" ``` + +`trim` *requires* the second argument, which tells the function specifically what to remove from the first argument. There is no default value for the second argument, so the following usage will *not* work: + +``` +{{ trim .Inner}} +``` + +Instead, the following example tells `trim` to remove extra new lines from the content contained in the `.Inner`, which has specific usage with [shortcodes](/templates/shortcode-templates/): + +``` +{{ trim .Inner "\n" }} +``` + +Go templates also provide a simple [method for trimming whitespace](/templates/introduction/#whitespace) from either side of a Go tag by including a hyphen (`-`). diff --git a/content/templates/introduction.md b/content/templates/introduction.md index ef66a5bf5..95b9378a8 100644 --- a/content/templates/introduction.md +++ b/content/templates/introduction.md @@ -14,14 +14,14 @@ menu: weight: 10 weight: 10 #rem draft: false -aliases: [/templates/introduction/,/layouts/introduction/,/layout/introduction/] +aliases: [/templates/introduction/,/layouts/introduction/,/layout/introduction/, /templates/go-templates/] toc: true --- Hugo uses the excellent [Go html/template][gohtmltemplate] library, an extremely lightweight engine that provides just the right amount of logic to be able to create any style of static website. If you have used other template systems from different languages or frameworks, you will find a lot of similarities in Go templates. -{{% note "Go Deep with the Go Docs" %}} -This is only a primer. For an in-depth look into Go templates, check the official [Go docs](http://golang.org/pkg/html/template/). +{{% note %}} +The following is only a primer on Go templates. For an in-depth look into Go templates, check the official [Go docs](http://golang.org/pkg/html/template/). {{% /note %}} ## Introduction to Go Templates