MCPcopy Create free account
hub / github.com/kataras/iris / Ace

Function Ace

view/ace.go:39–94  ·  view source on GitHub ↗

Ace returns a new Ace view engine. It shares the same exactly logic with the html view engine, it uses the same exactly configuration. The given "extension" MUST begin with a dot. Ace minifies the response automatically unless SetIndent() method is set. Read more about the Ace Go Parser: https://gi

(fs interface{}, extension string)

Source from the content-addressed store, hash-verified

37// Ace(iris.Dir("./views"), ".ace") or
38// Ace(embed.FS, ".ace") or Ace(AssetFile(), ".ace") for embedded data.
39func Ace(fs interface{}, extension string) *AceEngine {
40 s := &AceEngine{HTMLEngine: HTML(fs, extension), indent: ""}
41 s.name = "Ace"
42
43 funcs := make(map[string]interface{})
44
45 once := new(sync.Once)
46
47 s.middleware = func(name string, text []byte) (contents string, err error) {
48 once.Do(func() { // on first template parse, all funcs are given.
49 for k, v := range s.getBuiltinFuncs(name) {
50 funcs[k] = v
51 }
52
53 for k, v := range s.funcs {
54 funcs[k] = v
55 }
56 })
57
58 // name = path.Join(path.Clean(directory), name)
59
60 src := ace.NewSource(
61 ace.NewFile(name, text),
62 ace.NewFile("", []byte{}),
63 []*ace.File{},
64 )
65
66 if strings.Contains(name, "layout") {
67 for k, v := range s.layoutFuncs {
68 funcs[k] = v
69 }
70 }
71
72 opts := &ace.Options{
73 Extension: extension[1:],
74 FuncMap: funcs,
75 DelimLeft: s.left,
76 DelimRight: s.right,
77 Indent: s.indent,
78 }
79
80 rslt, err := ace.ParseSource(src, opts)
81 if err != nil {
82 return "", err
83 }
84
85 t, err := ace.CompileResult(name, rslt, opts)
86 if err != nil {
87 return "", err
88 }
89
90 return t.Lookup(name).Tree.Root.String(), nil
91 }
92
93 return s
94}

Callers

nothing calls this directly

Calls 6

HTMLFunction · 0.85
getBuiltinFuncsMethod · 0.80
ContainsMethod · 0.80
LookupMethod · 0.80
StringMethod · 0.65
DoMethod · 0.45

Tested by

no test coverage detected