1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-22 04:17:03 +00:00

make the macro#Parse to return a value of a Template instead of its ptr and debug logs for handlers length ignores the internal generated macro evaluator handler if it is there, so end-dev cannot be confused about the debug logs at that point

Former-commit-id: c23a3d10b43f145de575f1ea11e3dbf9bbd33a6b
This commit is contained in:
Gerasimos (Makis) Maropoulos
2018-09-29 19:59:39 +03:00
parent 4431a65a56
commit b08df3a785
6 changed files with 45 additions and 28 deletions

View File

@@ -95,18 +95,17 @@ func (p *TemplateParam) Eval(paramValue string, paramChanger memstore.ValueSette
// and returns a new Template.
// It builds all the parameter functions for that template
// and their evaluators, it's the api call that makes use the interpeter's parser -> lexer.
func Parse(src string, macros Macros) (*Template, error) {
func Parse(src string, macros Macros) (Template, error) {
types := make([]ast.ParamType, len(macros))
for i, m := range macros {
types[i] = m
}
tmpl := Template{Src: src}
params, err := parser.Parse(src, types)
if err != nil {
return nil, err
return tmpl, err
}
t := new(Template)
t.Src = src
for idx, p := range params {
m := macros.Lookup(p.Type)
@@ -140,8 +139,8 @@ func Parse(src string, macros Macros) (*Template, error) {
tmplParam.Funcs = append(tmplParam.Funcs, evalFn)
}
t.Params = append(t.Params, tmplParam.preComputed())
tmpl.Params = append(tmpl.Params, tmplParam.preComputed())
}
return t, nil
return tmpl, nil
}