Pipelines
Updated: November 24, 2025
Pipelines in Go templates allow chaining commands where the output of one becomes the input to the next.
Table of Contents
Data Commands
Access data fields from the template context.
{{.Title}} // Access Title field from data
{{.User.Name}} // Access nested fields
Functions
Call template functions with arguments.
{{template "content"}} // Call template function
{{len .Items}} // Call built-in len function
Methods
Call methods on data objects.
type Data struct {}
func (d Data) SayMsg(m string) string {
return m
}
{{.SayMsg "Hello World!"}} // Call method with argument
Pipes
Chain commands where output of one becomes input to next.
{{ command1 arg1 | command2 }} // Pipe result of command1 to command2
{{ .Name | printf "%s" | html }} // Chain multiple commands
Whitespace Control
Control whitespace in template output.
{{- "some string" -}} // Remove whitespace before and after
{{ "text" -}} // Remove whitespace after
{{- "text" }} // Remove whitespace before