Skip to content

mh-cbon/template-tree-simplifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

template-tree-simplifier

GoDoc

A package to simplify a template AST via a serie of transformations.

It transforms

{{"some" | split (("what" | lower) | up)}}

into

{{$var1 := lower "what"}}{{$var0 := up $var1}}{{split $var0 "some"}}

Install

go get github.com/mh-cbon/template-tree-simplifier
glide get github.com/mh-cbon/template-tree-simplifier

Usage

package main

import (
	"fmt"
	"github.com/mh-cbon/template-tree-simplifier/simplifier"
	"text/template"
)

func main() {
	file := "cli/tpl/test.tpl"
	fmt.Println(file)

	data := nil
	funcs := template.FuncMap{}

	tpl, err := template.New("").Funcs(funcs).ParseFiles(file)
	if err != nil {
		panic(err)
	}

	simplifier.Transform(t, data, funcs)
}

About

simplify a template AST via a serie of transformations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages