hugolib: Add .Name as a shortcode variable

Fixes #5546
This commit is contained in:
Bjørn Erik Pedersen
2018-12-21 09:51:15 +01:00
parent 6f069e549b
commit 1021714449
3 changed files with 8 additions and 2 deletions

View File

@@ -58,6 +58,7 @@ type ShortcodeWithPage struct {
Inner template.HTML
Page *PageWithoutContent
Parent *ShortcodeWithPage
Name string
IsNamedParams bool
// Zero-based ordinal in relation to its parent. If the parent is the page itself,
@@ -401,7 +402,7 @@ func renderShortcode(
return "", nil
}
data := &ShortcodeWithPage{Ordinal: sc.ordinal, posOffset: sc.pos, Params: sc.params, Page: p, Parent: parent}
data := &ShortcodeWithPage{Ordinal: sc.ordinal, posOffset: sc.pos, Params: sc.params, Page: p, Parent: parent, Name: sc.name}
if sc.params != nil {
data.IsNamedParams = reflect.TypeOf(sc.params).Kind() == reflect.Map
}