diff --git a/docs/content/templates/functions.md b/docs/content/templates/functions.md index b84a4ff35..9da9476ad 100644 --- a/docs/content/templates/functions.md +++ b/docs/content/templates/functions.md @@ -20,7 +20,9 @@ to create a good static website. Go templates are lightweight but extensible. Hugo has added the following functions to the basic template logic. -Go documentation for the built-in functions can be found [here](http://golang.org/pkg/text/template/) +(Go itself supplies built-in functions, including comparison operators +and other basic tools; these are listed in the +[Go template documentation](http://golang.org/pkg/text/template/#hdr-Functions).) ## General diff --git a/docs/content/templates/go-templates.md b/docs/content/templates/go-templates.md index 0ee6624fd..9cd528895 100644 --- a/docs/content/templates/go-templates.md +++ b/docs/content/templates/go-templates.md @@ -20,7 +20,7 @@ template systems from different languages or frameworks, you will find a lot of similarities in Go templates. This document is a brief primer on using Go templates. The [Go docs][gohtmltemplate] -provide more details. +go into more depth and cover features that aren't mentioned here. ## Introduction to Go Templates @@ -87,10 +87,17 @@ are useful for building websites. Functions are called by using their name followed by the required parameters separated by spaces. Template functions cannot be added without recompiling Hugo. -**Example:** +**Example 1: Adding numbers** {{ add 1 2 }} +**Example 2: Comparing numbers** + + {{ lt 1 2 }} + +(There are more boolean operators, detailed in the +[template documentation](http://golang.org/pkg/text/template/#hdr-Functions).) + ## Includes When including another template, you will pass to it the data it will be @@ -142,7 +149,6 @@ range. `if`, `else`, `with`, `or` & `and` provide the framework for handling conditional logic in Go Templates. Like `range`, each statement is closed with `end`. - Go Templates treat the following values as false: * false @@ -351,3 +357,23 @@ so, such as in this example: [go]: http://golang.org/ [gohtmltemplate]: http://golang.org/pkg/html/template/ + +# Template example: Show only upcoming events + +Go allows you to do more than what's shown here. Using Hugo's +[`where`](/templates/functions/#toc_4) function and Go built-ins, we can list +only the items from `content/events/` whose date (set in the front matter) is in +the future: + +