Base Go Template Functions

Base go template functions #

and #

func and(arg0 reflect.Value, args ...reflect.Value) reflect.Value
Returns the boolean AND of its arguments by returning the first empty
argument or the last argument, that is, "and x y" behaves as "if x
then y else x". All the arguments are evaluated.

call #

func call(fn reflect.Value, args ...reflect.Value) reflect.Value
Returns the result of calling the first argument, which must be a
function, with the remaining arguments as parameters. Thus "call .X.Y
1 2" is, in Go notation, dot.X.Y(1, 2) where Y is a func-valued field,
map entry, or the like. The first argument must be the result of an
evaluation that yields a value of function type (as distinct from a
predefined function such as print). The function must return either
one or two result values, the second of which is of type error. If the
arguments don't match the function or the returned error value is
non-nil, execution stops.

eq #

func eq(arg1 reflect.Value, arg2 ...reflect.Value) bool
Returns the boolean truth of arg1 == arg2

ge #

func ge(arg1 reflect.Value, arg2 ...reflect.Value) bool
Returns the boolean truth of arg1 >= arg2

gt #

func gt(arg1 reflect.Value, arg2 ...reflect.Value) bool
Returns the boolean truth of arg1 > arg2

html #

func html(args ...interface{}) string
Returns the escaped HTML equivalent of the textual representation of
its arguments. This function is unavailable in html/template, with a
few exceptions.

index #

func index(item reflect.Value, indices ...reflect.Value) reflect.Value
Returns the result of indexing its first argument by the following
arguments. Thus "index x 1 2 3" is, in Go syntax, x[1][2][3]. Each
indexed item must be a map, slice, or array.

js #

func js(args ...interface{}) string
Returns the escaped JavaScript equivalent of the textual
representation of its arguments.

le #

func le(arg1 reflect.Value, arg2 ...reflect.Value) bool
Returns the boolean truth of arg1 <= arg2

len #

func len(item interface{}) int
Returns the integer length of its argument.

lt #

func lt(arg1 reflect.Value, arg2 ...reflect.Value) bool
Returns the boolean truth of arg1 < arg2

ne #

func ne(arg1 reflect.Value, arg2 ...reflect.Value) bool
Returns the boolean truth of arg1 != arg2

not #

func not(not(arg reflect.Value) bool
Returns the boolean negation of its single argument.

or #

func or(or(arg0 reflect.Value, args ...reflect.Value) reflect.Value
Returns the boolean OR of its arguments by returning the first
non-empty argument or the last argument, that is, "or x y" behaves as
"if x then x else y". All the arguments are evaluated.

print #

func print(args ...interface{}) string
An alias for fmt.Sprint

printf #

func printf(format string, args ...interface{}) string
An alias for fmt.Sprintf

println #

func println(args ...interface{}) string
An alias for fmt.Sprintln

urlquery #

func urlquery(args ...interface{}) string
Returns the escaped value of the textual representation of its
arguments in a form suitable for embedding in a URL query. This
function is unavailable in html/template, with a few exceptions.