Documentation
¶
Overview ¶
Package vipertpl extends viper's functionality with ability to use golang templates in string variables
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCircularDependency = errors.New("circular dependency")
ErrCircularDependency is returned when there is a circular dependency caused by using tpl "ViperGet" function.
Functions ¶
func Parse ¶
Parse goes though all the keys stored in viper config and parses them with golang's internal templating engine.
Example ¶
package main
import (
"bytes"
"fmt"
"github.com/molecule-man/vipertpl"
"github.com/spf13/viper"
)
func main() {
input := []byte(`
foo: 'foo_val'
bar: 'bar_val + {{ ViperGet "foo" }}'
`)
viper.SetConfigType("yaml")
err := viper.ReadConfig(bytes.NewBuffer(input))
if err != nil {
panic(err)
}
err = vipertpl.Parse(viper.GetViper())
if err != nil {
panic(err)
}
fmt.Printf("%#v", viper.Get("bar"))
}
Output: "bar_val + foo_val"
Types ¶
Click to show internal directories.
Click to hide internal directories.