Using the ‘tpl’ Function

The tpl function allows developers to evaluate strings as templates inside a template.This is useful to pass a template string as a value to a chart or render external configuration files.Syntax: {{ tpl TEMPLATE_STRING VALUES }}

Examples:

  1. # values
  2. template: "{{ .Values.name }}"
  3. name: "Tom"
  4. # template
  5. {{ tpl .Values.template . }}
  6. # output
  7. Tom

Rendering a external configuration file:

  1. # external configuration file conf/app.conf
  2. firstName={{ .Values.firstName }}
  3. lastName={{ .Values.lastName }}
  4. # values
  5. firstName: Peter
  6. lastName: Parker
  7. # template
  8. {{ tpl (.Files.Get "conf/app.conf") . }}
  9. # output
  10. firstName=Peter
  11. lastName=Parker