mirror of
https://github.com/kovetskiy/mark.git
synced 2026-04-21 22:12:35 +00:00
small style fixes related to templates
This commit is contained in:
@@ -130,10 +130,10 @@ func ExtractMacros(
|
||||
"template",
|
||||
)
|
||||
config = regexputil.Subexp(reMacroDirective, groups, "config")
|
||||
|
||||
macro Macro
|
||||
)
|
||||
|
||||
var macro Macro
|
||||
|
||||
if strings.HasPrefix(template, "#") {
|
||||
cfg := map[string]interface{}{}
|
||||
|
||||
@@ -143,27 +143,38 @@ func ExtractMacros(
|
||||
err,
|
||||
"unable to unmarshal macros config template",
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
body, _ := cfg[template[1:]].(string)
|
||||
|
||||
body, ok := cfg[template[1:]].(string)
|
||||
if !ok {
|
||||
err = fmt.Errorf(
|
||||
"the template config doesn't have '%s' field",
|
||||
template[1:],
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
macro.Template, err = templates.New(template).Parse(body)
|
||||
if err != nil {
|
||||
err = karma.Format(
|
||||
err,
|
||||
"unable to parse template",
|
||||
)
|
||||
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
macro.Template, err = includes.LoadTemplate(base, template, "{{", "}}", templates)
|
||||
if err != nil {
|
||||
err = karma.Format(err, "unable to load template")
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
facts := karma.
|
||||
Describe("template", template).
|
||||
Describe("expr", expr)
|
||||
|
||||
Reference in New Issue
Block a user