module
Version:
v0.0.0-...-217b446
Opens a new window with list of versions in this module.
Published: Jun 17, 2019
License: MIT
Opens a new window with license information.
README
¶
YAML Templating Library for Golang
Introduction
yaml-template
uses text/template
as internal template engine. Check its document for details.
Installation
go get github.com/Spiderpowa/yaml-template
Example
package main
import (
"bytes"
"fmt"
"github.com/Spiderpowa/yaml-template/template"
)
func main() {
tmpl, err := template.New("test", "host: {{.host}}\nport: {{.port}}\nname: it's a test")
if err != nil {
panic(err)
}
buf := new(bytes.Buffer)
if err := tmpl.ApplyYaml([]byte("port: 3000\nhost: http://localhost"), buf); err != nil {
panic(err)
}
fmt.Println(buf.String())
}
The output is
host: http://localhost
port: 3000
name: it's a test
Documentation
Godoc
Template
Directories
¶
Click to show internal directories.
Click to hide internal directories.