DOC_INDEX
THEME
render
Render Go templates to produce configuration files, reports, and text output
Available since v0.8.0.
Render Go templates to produce text output. Use for generating configuration
files, reports, or any text content from templates and variables. Templates
render with the engine's full function set (Sprig pipes plus OrchStep
functions like regexFind), against the same context steps see
(vars, steps, env, stdin).
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
func | string | yes | Must be render |
args.template | string | one of | Inline template string |
args.template_file | string | one of | Path to a template file (path itself may contain templates) |
do | string | one of | Shorthand for args.template |
args.output_file | string | no | Also write the rendered output to this file |
Exactly one template source is required: args.template,
args.template_file, or the do: shorthand.
Return Values
| Field | Description |
|---|---|
result.output | The rendered text |
result.exit_code | 0 on success |
result.status | "success" |
Examples
Inline template
- name: render_config
func: render
args:
template: |
app = {{ vars.app_name }}
replicas = {{ vars.replicas }}
app_upper = {{ vars.app_name | upper }}
outputs:
config: "{{ result.output }}"Template file to output file
- name: render_nginx
func: render
args:
template_file: "templates/nginx.conf.tmpl"
output_file: "build/{{ vars.env_name }}/nginx.conf"Shorthand
- name: banner
func: render
do: "deploying {{ vars.app_name }} v{{ vars.version }} to {{ vars.env_name }}"Consuming rendered output
- name: tpl
func: render
args:
template: "host={{ vars.db_host }}"
- name: verify
func: assert
args:
condition: '{{ contains "host=" steps.tpl.output }}'Notes
- The full template function set is available - the same one used in
do:/argsrendering andoutputs:extraction. - For ad-hoc experiments, test template expressions with
orchstep evalbefore putting them in a template.