mirror of
https://github.com/gohugoio/hugo.git
synced 2025-06-29 04:09:51 +00: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:
parent
6142bc701c
commit
61317821e4
6 changed files with 127 additions and 24 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue