diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2017-05-01 21:37:49 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2017-05-01 22:21:44 -0400 |
| commit | 30a58ee79241423d4fe1d914b3b32fc7aae72b5b (patch) | |
| tree | 2aa2ec6160ad7403b88af32d38e47e15a100e998 /README.md | |
| parent | 474e4857bd79fefb45baccc10803c0ebdb541700 (diff) | |
Add urlParse function (i.e. url.Parse)
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -65,6 +65,8 @@ Gomplate is an alternative that will let you process templates which also includ - [Example](#example) - [`trim`](#trim) - [Example](#example) + - [`urlParse`](#urlparse) + - [Example](#example) - [`has`](#has) - [Example](#example) - [`json`](#json) @@ -433,6 +435,27 @@ $ FOO=" world " | gomplate < input.tmpl Hello, world! ``` +#### `urlParse` + +Parses a string as a URL for later use. Equivalent to [url.Parse](https://golang.org/pkg/net/url/#Parse) + +##### Example + +_`input.tmpl`:_ +``` +{{ $u := urlParse "https://example.com:443/foo/bar" }} +The scheme is {{ $u.Scheme }} +The host is {{ $u.Host }} +The path is {{ $u.Path }} +``` + +```console +$ gomplate < input.tmpl +The scheme is https +The host is example.com:443 +The path is /foo/bar +``` + #### `has` Has reports whether or not a given object has a property with the given key. Can be used with `if` to prevent the template from trying to access a non-existent property in an object. |
