mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Adding Else If example
This commit is contained in:
parent
ed0fe9ddf7
commit
5cff3e6219
1 changed files with 10 additions and 3 deletions
|
@ -129,7 +129,7 @@ range.
|
||||||
|
|
||||||
If, else, with, or, & and provide the framework for handling conditional
|
If, else, with, or, & and provide the framework for handling conditional
|
||||||
logic in Go Templates. Like range, each statement is closed with `end`.
|
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:
|
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 }}
|
{{ 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
|
## Pipes
|
||||||
|
|
||||||
One of the most powerful components of go templates is the ability to
|
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:
|
Here is the corresponding code inside of the template:
|
||||||
|
|
||||||
{{ if .Params.notoc }}
|
{{ if not .Params.notoc }}
|
||||||
{{ else }}
|
|
||||||
<div id="toc" class="well col-md-4 col-sm-6">
|
<div id="toc" class="well col-md-4 col-sm-6">
|
||||||
{{ .TableOfContents }}
|
{{ .TableOfContents }}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue