From: spf13 Date: Wed, 19 Feb 2014 13:32:18 +0000 (-0500) Subject: Adding Else If example X-Git-Tag: v0.10~17 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5cff3e62198e83957b6163e71fcaf822ccb86c38;p=brevno-suite%2Fhugo Adding Else If example --- diff --git a/docs/content/layout/go-templates.md b/docs/content/layout/go-templates.md index 39df738e..b6a92b35 100644 --- a/docs/content/layout/go-templates.md +++ b/docs/content/layout/go-templates.md @@ -129,7 +129,7 @@ range. If, else, with, or, & and provide the framework for handling conditional logic in Go Templates. Like range, each statement is closed with `end`. -There is not an elseif function. + Go Templates treat the following values as false: @@ -163,6 +163,14 @@ The first example above could be simplified as: {{ with .Params.title }}

{{ . }}

{{ end }} +**Example 5: If -> Else If ** + + {{ if isset .Params "alt" }} + {{ index .Params "alt" }} + {{ else if isset .Params "caption" }} + {{ index .Params "caption" }} + {{ end }} + ## Pipes One of the most powerful components of go templates is the ability to @@ -263,8 +271,7 @@ notoc: true Here is the corresponding code inside of the template: - {{ if .Params.notoc }} - {{ else }} + {{ if not .Params.notoc }}
{{ .TableOfContents }}