Go template functions, operators, and statements
These are the functions, operators, and statements provided by Go’s text/template package.
These are the functions, operators, and statements provided by Go’s text/template package.
and VALUE... ⟼ anyReturns the first falsy argument. If all arguments are truthy, returns the last argument. Read More »
block NAME CONTEXTDefines a template and executes it in place. Read More »
breakUsed with the range statement, stops the innermost iteration and bypasses all remaining iterations. Read More »
continueUsed with the range statement, stops the innermost iteration and continues to the next iteration. Read More »
define NAMEDefines a template. Read More »
else VALUEBegins an alternate block for if, with, and range statements. Read More »
endTerminates if, with, range, block, and define statements. Read More »
if EXPRExecutes the block if the expression is truthy. Read More »
len VALUE ⟼ intReturns the length of a string, slice, map, or collection. Read More »
not VALUE ⟼ boolReturns the boolean negation of its single argument. Read More »
or VALUE... ⟼ anyReturns the first truthy argument. If all arguments are falsy, returns the last argument. Read More »
range COLLECTIONIterates over a non-empty collection, binds context (the dot) to successive elements, and executes the block. Read More »
return [VALUE] ⟼ anyUsed within partial templates, terminates template execution and returns the given value, if any. Read More »
template NAME [CONTEXT]Executes the given template, optionally passing context. Read More »
urlquery VALUE [VALUE...] ⟼ stringReturns the escaped value of the textual representation of its arguments in a form suitable for embedding in a URL query. Read More »
with EXPRBinds context (the dot) to the expression and executes the block if expression is truthy. Read More »