TemplateDataLoader render.Loader
}
-func Compile(root TemplateSource, transform ...func(root *html.Node)) (Result, error) {
- var result Result
+func Compile(root TemplateSource, transform ...func(root *html.Node)) ([]Result, error) {
reader, err := root.Source().Open()
if err != nil {
- return result, err
+ return nil, err
}
document, err := html.Parse(reader)
if err != nil {
- return result, err
+ return nil, err
}
fullDependencies := Sources{root.Name(): root}
}
err := insertComponentSource(subSource, document)
if err != nil {
- return result, err
+ return nil, err
}
delete(fullDependencies, name)
}
}
err = process(document, computeRoot)
if err != nil {
- return result, err
+ return nil, err
}
// POSTPROCESSING
raw, err := renderDocument(document)
if err != nil {
- return result, err
+ return nil, err
}
- result = Result{
+ result := Result{
TemplateRaw: raw,
TemplateFuncs: templateFuncs,
TemplateDataLoader: computeRoot,
}
- return result, err
+ return []Result{result}, nil
}
func renderDocument(document *html.Node) (string, error) {
if p.indent != "" {
sourceTransform = htmltree.Prettify(p.indent)
}
- result, err := compile.Compile(p, sourceTransform)
+ results, err := compile.Compile(p, sourceTransform)
if err != nil {
p.err = err
return p
}
+ result := results[0]
p.raw = result.TemplateRaw
p.templateLoad = result.TemplateDataLoader