Skip to content

Commit a3ea26b

Browse files
committed
Add "Templating" section to the README
1 parent 937c7b0 commit a3ea26b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,25 @@ If no `<dest>` file is specified, the output is sent to stdout. Mainly useful f
9595

9696
===
9797

98+
### Templating
99+
100+
The templates used by nginx-proxy are written the Go [text/template](http://golang.org/pkg/text/template/) language. In addition to the [built-in functions](http://golang.org/pkg/text/template/#hdr-Functions) supplied by Go, nginx-proxy provides a number of additional functions to make it simpler (or possible) to generate your desired output.
101+
102+
#### Functions
103+
104+
* *`contains $map $key`*: Returns `true` if `$map` contains `$key`. Takes maps from `string` to `string`.
105+
* *`exists $path`*: Returns `true` if `$path` refers to an existing file or directory. Takes a string.
106+
* *`groupBy $containers $fieldPath`*: Groups an array of `RuntimeContainer` instances based on the values of a field path expression `$fieldPath`. A field path expression is a dot-delimited list of map keys or struct member names specifying the path from container to a nested value, which must be a string. Returns a map from the value of the field path expression to an array of containers having that value. Containers that do not have a value for the field path in question are omitted.
107+
* *`groupByMulti $containers $fieldPath $sep`*: Like `groupBy`, but the string value specified by `$fieldPath` is first split by `$sep` into a list of strings. A container whose `$fieldPath` value contains a list of strings will show up in the map output under each of those strings.
108+
* *`split $string $sep`*: Splits `$string` into a slice of substrings delimited by `$sep`. Alias for [`strings.Split`](http://golang.org/pkg/strings/#Split)
109+
* *`replace $string $old $new $count`*: Replaces up to `$count` occurences of `$old` with `$new` in `$string`. Alias for [`strings.Replace`](http://golang.org/pkg/strings/#Replace)
110+
* *`dict $key $value ...`*: Creates a map from a list of pairs. Each `$key` value must be a `string`, but the `$value` can be any type (or `nil`). Useful for passing more than one value as a pipeline context to subtemplates.
111+
* *`sha1 $string`*: Returns the hexadecimal representation of the SHA1 hash of `$string`.
112+
* *`json $value`*: Returns the JSON representation of `$value` as a `string`.
113+
* *`last $array`*: Returns the last value of an array.
114+
115+
===
116+
98117
### Examples
99118

100119
* [Automated Nginx Reverse Proxy for Docker](http://jasonwilder.com/blog/2014/03/25/automated-nginx-reverse-proxy-for-docker/)

0 commit comments

Comments
 (0)