Home / Go / html templating edit

## if
if returns false for false booleans, empty strings, empty slices

{{ if .Foo }} ... {{ end }}

{{ if not .Foo }} ... {{ end }}

## Slices: iterate, get length

{{ range .Slice }} ... {{ end }}

{{ len .Slice }}

## Variables

{{ $isAdmin := .IsAdmin }}

{{ if $isAdmin }} ... {{ end }}

## Include another template

{{ template "foo.html" }}

This includes a template named "foo".
Go to index of articles.

Share on