summaryrefslogtreecommitdiffstats
path: root/tpl/template.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-08-01 18:12:36 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-08-03 20:00:57 +0200
commitade7ec818798c0e5507d4fb6cc5b4396262a85d6 (patch)
treefe1e2e18922b20286113d66e171dfecc861d30ff /tpl/template.go
parent8fa8ce3e48c8812daa1eecc8865b653336d98147 (diff)
Add Page.RenderShortcodes
A layouts/shortcodes/include.html shortcode may look like this: ```html {{ $p := site.GetPage (.Get 0) }} {{ $p.RenderShortcodes }} ``` Fixes #7297
Diffstat (limited to 'tpl/template.go')
-rw-r--r--tpl/template.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/tpl/template.go b/tpl/template.go
index 91a482c25..70fdf2d3d 100644
--- a/tpl/template.go
+++ b/tpl/template.go
@@ -191,6 +191,14 @@ func SetHasLockInContext(ctx context.Context, hasLock bool) context.Context {
return context.WithValue(ctx, texttemplate.HasLockContextKey, hasLock)
}
+func GetCallbackFunctionFromContext(ctx context.Context) any {
+ return ctx.Value(texttemplate.CallbackContextKey)
+}
+
+func SetCallbackFunctionInContext(ctx context.Context, fn any) context.Context {
+ return context.WithValue(ctx, texttemplate.CallbackContextKey, fn)
+}
+
const hugoNewLinePlaceholder = "___hugonl_"
var (