2017-03-12 21:58:49 -05:00

835 B

title linktitle description godocref date publishdate lastmod categories tags signature workson hugoversion relatedfuncs deprecated
with with Rebinds the context (`.`) within its scope and skips the block if the variable is absent. 2017-03-12 2017-03-12 2017-03-12
functions
conditionals
fundamentals
false

An alternative way of writing the "if" and then referencing the same value is to use with instead. with rebinds the context (.) within its scope and skips the block if the variable is absent:

{{% code file="layouts/partials/twitter.html" %}}

{{with .Site.Params.TwitterUser}}<span class="twitter">
<a href="https://twitter.com/{{.}}" rel="author">
<img src="/images/twitter.png" width="48" height="48" title="Twitter: {{.}}"
 alt="Twitter"></a>
</span>{{end}}

{{% /code %}}