Skip to content

Template reference

Ruphish evaluates Go-style text templates. Expressions are case-sensitive and enclosed in {{ and }}. They are executed expressions, not a simple string-replacement vocabulary.

ExpressionValue
{{.FirstName}}Recipient’s first name
{{.LastName}}Recipient’s last name
{{.Email}}Recipient’s email address
{{.Position}}Recipient’s position
{{.From}}Sender context supplied for the message
{{.URL}}Personalized campaign URL
{{.RId}}Opaque public recipient identifier
{{.BaseURL}}Campaign origin without its path/query
{{.TrackingURL}}Tracking-image URL
{{.Tracker}}Complete tracking-image markup

These tracking fields remain available for legacy templates. New email templates need neither: the sender automatically inserts one hidden tracking image in HTML, and previews remove rendered tracking images. Plain-text-only emails remain plain text.

A recognized field can be empty. An unknown field, including a wrong-case field such as .email, produces an execution error rather than silently becoming an empty string.

Hello {{if .FirstName}}{{.FirstName}}{{else}}there{{end}},
Your exercise link: {{.URL}}

Variables, if/else, with, range, named templates with define/template, comments, and pipelines are supported by the renderer. Expressions must receive appropriate values: for example, ranging over a recipient’s name is not a supported collection operation.

{{$name := .FirstName}}{{with .LastName}}{{$name}} {{.}}{{end}}
{{printf "%s" .Email | printf "[%s]"}}

The renderer includes Go-style built-ins for boolean/comparison operations, formatting, indexing/slicing, length, and explicit escaping. Use the ordinary text-template functions (and, or, not, eq, ne, lt, le, gt, ge, print, printf, println, index, slice, len, html, js, and urlquery) with arguments of the appropriate type. Application-specific Sprig functions or arbitrary Go methods are not an extension interface.

Text-template evaluation does not automatically HTML-escape recipient values. Choose explicit escaping for the context in which a value is inserted. The served landing page is subsequently restricted by the participant-page policy; that separate boundary is not contextual template escaping.

String length and indexing follow byte-oriented compatibility behavior. A slice that splits a UTF-8 character is rejected, rather than returning invalid UTF-8. For example, {{slice "José" 3 5}} yields é; slicing only one byte of that character fails.

Invalid syntax fails parsing; missing fields, invalid function arguments, or an absent named template can fail execution. Rendering is bounded for nesting, iteration, allocation, and output. Resource documents and rendered output have an 8 MiB limit. Treat a failed render as an error, not as a usable partial message.

Preview with representative values before launch, including empty optional names and non-ASCII text. Template rendering does not fetch arbitrary external data. Imported content retains its expressions; import is not a conversion to a different template language.

See email templates, landing pages, and attachments for where these expressions are used.