mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-23 21:53:09 +02:00
tpl: Narrow down the usage of plain text shortcodes when rendering HTML
After this commit, if you want to resolve `layouts/_shortcodes/myshortcode.txt` when rendering HTML content, you need to use the `{{%` shortcode delimiter: ``` {{% myshortcode %}} ``` This should be what people would do anyway, but we have also as part of this improved the error message to inform about what needs to be done. Note that this is not relevant for partials. Fixes #13698
This commit is contained in:
@@ -398,6 +398,10 @@ func doRenderShortcode(
|
||||
return true
|
||||
}
|
||||
base, layoutDescriptor := po.GetInternalTemplateBasePathAndDescriptor()
|
||||
|
||||
// With shortcodes/mymarkdown.md (only), this allows {{% mymarkdown %}} when rendering HTML,
|
||||
// but will not resolve any template when doing {{< mymarkdown >}}.
|
||||
layoutDescriptor.AlwaysAllowPlainText = sc.doMarkup
|
||||
q := tplimpl.TemplateQuery{
|
||||
Path: base,
|
||||
Name: sc.name,
|
||||
@@ -405,10 +409,9 @@ func doRenderShortcode(
|
||||
Desc: layoutDescriptor,
|
||||
Consider: include,
|
||||
}
|
||||
v := s.TemplateStore.LookupShortcode(q)
|
||||
v, err := s.TemplateStore.LookupShortcode(q)
|
||||
if v == nil {
|
||||
s.Log.Errorf("Unable to locate template for shortcode %q in page %q", sc.name, p.File().Path())
|
||||
return zeroShortcode, nil
|
||||
return zeroShortcode, err
|
||||
}
|
||||
tmpl = v
|
||||
hasVariants = hasVariants || len(ofCount) > 1
|
||||
|
Reference in New Issue
Block a user