From b8797404d01fc222cf22535ff57ab925aed4d88d Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Sat, 10 Nov 2018 11:16:28 -0500 Subject: New tpl function Signed-off-by: Dave Henderson --- docs-src/content/functions/other.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 docs-src/content/functions/other.yml (limited to 'docs-src/content') diff --git a/docs-src/content/functions/other.yml b/docs-src/content/functions/other.yml new file mode 100644 index 00000000..d26e9243 --- /dev/null +++ b/docs-src/content/functions/other.yml @@ -0,0 +1,36 @@ +ns: _ +title: Other functions +preamble: | + Miscellaneous functions that aren't part of a specific namespace. Most of these are fairly special-purpose. +funcs: + - name: tpl + description: | + Render the given string as a template, just like a nested template. + + If the template is given a name (see `name` argument below), it can be re-used later with the `template` keyword. + + A context can be provided, otherwise the default gomplate context will be used. + pipeline: false + arguments: + - name: name + required: false + description: The template's name. + - name: in + required: true + description: The template to render, as a string + - name: context + required: false + description: The context to use when rendering - this becomes `.` inside the template. + examples: + - | + $ gomplate -i '{{ tpl "{{print `hello world`}}" }}' + hello world + - | + $ gomplate -i ' + {{ $tstring := "{{ print .value ` world` }}" }} + {{ $context := dict "value" "hello" }} + {{ tpl "T1" $tstring $context }} + {{ template "T1" (dict "value" "goodbye") }} + ' + hello world + goodbye world -- cgit v1.2.3