func newTestCtx(t test.Tester) *testctx { c := &testctx{ test.NewCtx(t), nil, } // generate Xslate arguments args := Args{ "Parser": Args{ "Syntax": "TTerse", }, "Loader": Args{ "LoadPaths": []string{c.BaseDir}, "CacheDir": c.Mkpath("cache"), "CacheLevel": 1, }, } c.XslateArgs = args return c }
func TestCompile_Wrapper(t *testing.T) { c := test.NewCtx(t) defer c.Cleanup() index := c.File("index.tx") index.WriteString(`[% WRAPPER "wrapper.tx" %]Hello[% END %]`) c.File("wrapper.tx").WriteString(`Hello, [% content %], Hello`) p := tterse.New() ast, err := p.Parse("index.tx", index.Read()) if err != nil { t.Fatalf("Failed to parse template: %s", err) } comp := New() bc, err := comp.Compile(ast) if err != nil { t.Fatalf("Failed to compile ast: %s", err) } t.Logf("-> %+v", bc) }