summaryrefslogtreecommitdiff
path: root/src/pkg/text/template/doc.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/text/template/doc.go')
-rw-r--r--src/pkg/text/template/doc.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/pkg/text/template/doc.go b/src/pkg/text/template/doc.go
index aa50ab97f..2da339ce8 100644
--- a/src/pkg/text/template/doc.go
+++ b/src/pkg/text/template/doc.go
@@ -63,16 +63,16 @@ data, defined in detail below.
otherwise, T1 is executed. Dot is unaffected.
{{range pipeline}} T1 {{end}}
- The value of the pipeline must be an array, slice, or map. If
- the value of the pipeline has length zero, nothing is output;
+ The value of the pipeline must be an array, slice, map, or channel.
+ If the value of the pipeline has length zero, nothing is output;
otherwise, dot is set to the successive elements of the array,
slice, or map and T1 is executed. If the value is a map and the
keys are of basic type with a defined order ("comparable"), the
elements will be visited in sorted key order.
{{range pipeline}} T1 {{else}} T0 {{end}}
- The value of the pipeline must be an array, slice, or map. If
- the value of the pipeline has length zero, dot is unaffected and
+ The value of the pipeline must be an array, slice, map, or channel.
+ If the value of the pipeline has length zero, dot is unaffected and
T0 is executed; otherwise, dot is set to the successive elements
of the array, slice, or map and T1 is executed.
@@ -100,6 +100,7 @@ An argument is a simple value, denoted by one of the following.
- A boolean, string, character, integer, floating-point, imaginary
or complex constant in Go syntax. These behave like Go's untyped
constants, although raw strings may not span newlines.
+ - The keyword nil, representing an untyped Go nil.
- The character '.' (period):
.
The result is the value of dot.
@@ -147,6 +148,10 @@ An argument is a simple value, denoted by one of the following.
The result is the value of invoking the function, fun(). The return
types and values behave as in methods. Functions and function
names are described below.
+ - A parenthesized instance of one the above, for grouping. The result
+ may be accessed by a field or map key invocation.
+ print (.F1 arg1) (.F2 arg2)
+ (.StructValuedMethod "arg").Field
Arguments may evaluate to any type; if they are pointers the implementation
automatically indirects to the base type when required.
@@ -198,7 +203,7 @@ If a "range" action initializes a variable, the variable is set to the
successive elements of the iteration. Also, a "range" may declare two
variables, separated by a comma:
- $index, $element := pipeline
+ range $index, $element := pipeline
in which case $index and $element are set to the successive values of the
array/slice index or map key and element, respectively. Note that if there is
@@ -227,6 +232,8 @@ All produce the quoted word "output":
{{"output" | printf "%q"}}
A function call whose final argument comes from the previous
command.
+ {{printf "%q" (print "out" "put")}}
+ A parenthesized argument.
{{"put" | printf "%s%s" "out" | printf "%q"}}
A more elaborate call.
{{"output" | printf "%s" | printf "%q"}}