Skip to main content

render

Function render 

Source
pub fn render(template: &str, vars: &TemplateVars) -> Result<String>
Expand description

Render a template string with the given variables.

Supports both Go-style ({{ .Field }}) and native Tera-style ({{ Field }}). Go-style references are preprocessed into Tera-style before rendering.

Because this uses Tera under the hood, all Tera features are available: conditionals ({% if %} / {% else %} / {% endif %}), loops ({% for %}), filters (| lower, | upper, | default, | trim, | title, | replace, etc.).

Custom GoReleaser-compat filters are registered:

  • tolower / toupper — aliases for Tera’s built-in lower / upper
  • trimprefix(prefix="v") — strip a prefix from a string
  • trimsuffix(suffix=".exe") — strip a suffix from a string