mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 22:21:07 +03:00
Add render template hooks for links and images
This commit also * revises the change detection for templates used by content files in server mode. * Adds a Page.RenderString method Fixes #6545 Fixes #4663 Closes #6043
This commit is contained in:
parent
67f3aa72cf
commit
e625088ef5
59 changed files with 2234 additions and 542 deletions
|
@ -23,8 +23,6 @@ import (
|
|||
"html/template"
|
||||
"path"
|
||||
|
||||
"github.com/gohugoio/hugo/markup/converter"
|
||||
|
||||
"github.com/gohugoio/hugo/common/herrors"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
|
@ -198,7 +196,7 @@ type shortcode struct {
|
|||
}
|
||||
|
||||
func (s shortcode) insertPlaceholder() bool {
|
||||
return !s.doMarkup || s.info.Config.Version == 1
|
||||
return !s.doMarkup || s.info.ParseInfo().Config.Version == 1
|
||||
}
|
||||
|
||||
func (s shortcode) innerString() string {
|
||||
|
@ -349,14 +347,9 @@ func renderShortcode(
|
|||
|
||||
// Pre Hugo 0.55 this was the behaviour even for the outer-most
|
||||
// shortcode.
|
||||
if sc.doMarkup && (level > 0 || sc.info.Config.Version == 1) {
|
||||
if sc.doMarkup && (level > 0 || sc.info.ParseInfo().Config.Version == 1) {
|
||||
var err error
|
||||
|
||||
b, err := p.getContentConverter().Convert(
|
||||
converter.RenderContext{
|
||||
Src: []byte(inner),
|
||||
},
|
||||
)
|
||||
b, err := p.pageOutput.cp.renderContent([]byte(inner), false)
|
||||
|
||||
if err != nil {
|
||||
return "", false, err
|
||||
|
@ -494,13 +487,13 @@ Loop:
|
|||
case currItem.IsRightShortcodeDelim():
|
||||
// we trust the template on this:
|
||||
// if there's no inner, we're done
|
||||
if !sc.isInline && !sc.info.IsInner {
|
||||
if !sc.isInline && !sc.info.ParseInfo().IsInner {
|
||||
return sc, nil
|
||||
}
|
||||
|
||||
case currItem.IsShortcodeClose():
|
||||
next := pt.Peek()
|
||||
if !sc.isInline && !sc.info.IsInner {
|
||||
if !sc.isInline && !sc.info.ParseInfo().IsInner {
|
||||
if next.IsError() {
|
||||
// return that error, more specific
|
||||
continue
|
||||
|
@ -540,7 +533,7 @@ Loop:
|
|||
return nil, _errors.Errorf("template for shortcode %q not found", sc.name)
|
||||
}
|
||||
|
||||
sc.info = tmpl.(tpl.TemplateInfoProvider).TemplateInfo()
|
||||
sc.info = tmpl.(tpl.Info)
|
||||
case currItem.IsInlineShortcodeName():
|
||||
sc.name = currItem.ValStr()
|
||||
sc.isInline = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue