Adding Else If example - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 5cff3e62198e83957b6163e71fcaf822ccb86c38
DIR parent ed0fe9ddf7b1c5df1d190979a0005747815b732a
HTML Author: spf13 <steve.francia@gmail.com>
Date: Wed, 19 Feb 2014 08:32:18 -0500
Adding Else If example
Diffstat:
M docs/content/layout/go-templates.md | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
---
DIR diff --git 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 }}<h4>{{ . }}</h4>{{ 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 }}
<div id="toc" class="well col-md-4 col-sm-6">
{{ .TableOfContents }}
</div>