Fix broken shortcodes for Ace and Amber

Fixes #4051
This commit is contained in:
Bjørn Erik Pedersen
2017-11-18 10:18:41 +01:00
parent b3daa1f4bf
commit 503ca6de6c
3 changed files with 57 additions and 15 deletions

View File

@@ -622,7 +622,8 @@ func (t *templateHandler) addTemplateFile(name, baseTemplatePath, path string) e
switch ext {
case ".amber":
// Only HTML support for Amber
templateName := strings.TrimSuffix(name, filepath.Ext(name)) + ".html"
withoutExt := strings.TrimSuffix(name, filepath.Ext(name))
templateName := withoutExt + ".html"
b, err := afero.ReadFile(t.Fs.Source, path)
if err != nil {
@@ -636,7 +637,19 @@ func (t *templateHandler) addTemplateFile(name, baseTemplatePath, path string) e
return err
}
return applyTemplateTransformersToHMLTTemplate(templ)
if err := applyTemplateTransformersToHMLTTemplate(templ); err != nil {
return err
}
if strings.Contains(templateName, "shortcodes") {
// We need to keep track of one ot the output format's shortcode template
// without knowing the rendering context.
clone := template.Must(templ.Clone())
t.html.t.AddParseTree(withoutExt, clone.Tree)
}
return nil
case ".ace":
// Only HTML support for Ace
var innerContent, baseContent []byte