template-tree-simplifier

module
v0.0.0-...-bb0b385 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2017 License: MIT

README

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)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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