github.com/suntong/easygen@v5.3.0+incompatible/egCal/example_test.go (about)

     1  package egCal_test
     2  
     3  import (
     4  	"os"
     5  
     6  	"github.com/go-easygen/easygen"
     7  	"github.com/go-easygen/easygen/egCal"
     8  	"github.com/go-easygen/easygen/egVar"
     9  )
    10  
    11  // for standalone test, change package to `main` and the next func def to,
    12  // func main() {
    13  func Example() {
    14  	tmpl0 := easygen.NewTemplate().Customize()
    15  	tmpl := tmpl0.Funcs(easygen.FuncDefs()).Funcs(egVar.FuncDefs()).Funcs(egCal.FuncDefs())
    16  	err := easygen.Process0(tmpl, os.Stdout,
    17  		"{{.Name}}: {{clk2uc .Name}} {{clk2ss .Name}}\n"+
    18  			"Cal: {{add 2 3}}, {{multiply 2 3}}, {{subtract 9 2}}, {{divide 24 3}}\n",
    19  		"../test/var0")
    20  
    21  	// Output:
    22  	// some-init-method: SomeInitMethod SOME_INIT_METHOD
    23  	// Cal: 5, 6, 7, 8
    24  
    25  	if err != nil {
    26  		panic(err)
    27  	}
    28  }
    29  
    30  // To show the full code in GoDoc
    31  type dummy struct {
    32  }