HUGO
Menu
GitHub 90612 stars Mastodon

end

Terminates if, with, range, block, and define statements.
Syntax
end

Usage

The end statement terminates the block that begins with an if, with, range, block, or define statement. Each of these statements requires a matching end statement.

See Go’s text/template documentation for more information.

Examples

With an if statement:

{{ $var := "foo" }}
{{ if $var }}
  {{ $var }} → foo
{{ end }}

With a with statement:

{{ $var := "foo" }}
{{ with $var }}
  {{ . }} → foo
{{ end }}

With a range statement:

{{ $var := slice 1 2 3 }}
{{ range $var }}
  {{ . }} → 1 2 3
{{ end }}

With a block statement:

{{ block "main" . }}{{ end }}

With a define statement:

{{ define "main" }}
  {{ print "this is the main section" }}
{{ end }}