yaml-template

module
v0.0.0-...-217b446 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: MIT

README

YAML Templating Library for Golang

CircleCI

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

Path Synopsis

Jump to

Keyboard shortcuts

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