github.com/bilus/oya@v0.0.3-0.20190301162104-da4acbd394c6/pkg/template/kasia.go (about)

     1  package template
     2  
     3  import (
     4  	"io"
     5  
     6  	kasia "github.com/ziutek/kasia.go"
     7  )
     8  
     9  type kasiaTemplate struct {
    10  	impl *kasia.Template
    11  }
    12  
    13  // parseKasia parses a kasia template in the source string.
    14  func parseKasia(source string) (Template, error) {
    15  	kt, err := kasia.Parse(source)
    16  	if err != nil {
    17  		return nil, err
    18  	}
    19  	kt.Strict = true
    20  	kt.EscapeFunc = nil
    21  	return kasiaTemplate{impl: kt}, nil
    22  }
    23  
    24  // Render writes the result of rendering the kasia template using the provided values to the IO writer.
    25  func (t kasiaTemplate) Render(out io.Writer, values ...interface{}) error {
    26  	return t.impl.Run(out, values...)
    27  }
    28  
    29  // Render returns the result of rendering the kasia template using the provided values.
    30  func (t kasiaTemplate) RenderString(values ...interface{}) (string, error) {
    31  	return t.impl.RenderString(values...)
    32  }