interpolate

package
v1.19.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2021 License: MIT Imports: 4 Imported by: 2

Documentation

Overview

Code generated by ragel @generated

Index

Constants

This section is empty.

Variables

EnvResolver is a VariableResolver that maps every variable to an environment variable.

Functions

This section is empty.

Types

type String

type String []term

String is a string that supports interpolation given some source of variable values.

func Parse

func Parse(data string) (out String, _ error)

Parse parses a string for interpolation.

Variables may be specified anywhere in the string in the format ${foo} or ${foo:default} where 'default' will be used if the variable foo was unset.

func (String) Render

func (s String) Render(resolve VariableResolver) (string, error)

Render renders and returns the string. The provided VariableResolver will be used to determine values for the different variables mentioned in the string.

func (String) RenderTo

func (s String) RenderTo(w io.Writer, resolve VariableResolver) error

RenderTo renders the string into the given writer. The provided VariableResolver will be used to determine values for the different variables mentioned in the string.

type VariableResolver

type VariableResolver func(name string) (value string, ok bool)

VariableResolver resolves the value of a variable specified in the string.

The boolean value indicates whether this variable had a value defined. If a variable does not have a value and no default is specified, rendering will fail.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL