mirror of
https://github.com/kovetskiy/mark.git
synced 2026-04-21 22:12:35 +00:00
introduce inline templates (#198)
This commit is contained in:
@@ -134,13 +134,36 @@ func ExtractMacros(
|
||||
macro Macro
|
||||
)
|
||||
|
||||
macro.Template, err = includes.LoadTemplate(base, template, templates)
|
||||
if err != nil {
|
||||
err = karma.Format(err, "unable to load template")
|
||||
if strings.HasPrefix(template, "#") {
|
||||
cfg := map[string]interface{}{}
|
||||
|
||||
return nil
|
||||
err = yaml.Unmarshal([]byte(config), &cfg)
|
||||
if err != nil {
|
||||
err = karma.Format(
|
||||
err,
|
||||
"unable to unmarshal macros config template",
|
||||
)
|
||||
return nil
|
||||
}
|
||||
body, _ := cfg[template[1:]].(string)
|
||||
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