summaryrefslogtreecommitdiffstats
path: root/tpl/template_info.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-11-27 13:42:36 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-12-18 11:44:40 +0100
commite625088ef5a970388ad50e464e87db56b358dac4 (patch)
treef7b26dec1f3695411558d05ca7d0995817a42250 /tpl/template_info.go
parent67f3aa72cf9aaf3d6e447fa6bc12de704d46adf7 (diff)
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
Diffstat (limited to 'tpl/template_info.go')
-rw-r--r--tpl/template_info.go52
1 files changed, 46 insertions, 6 deletions
diff --git a/tpl/template_info.go b/tpl/template_info.go
index be0566958..d9b438138 100644
--- a/tpl/template_info.go
+++ b/tpl/template_info.go
@@ -13,12 +13,44 @@
package tpl
+import (
+ "github.com/gohugoio/hugo/identity"
+)
+
// Increments on breaking changes.
const TemplateVersion = 2
-// Info holds some info extracted from a parsed template.
-type Info struct {
+type Info interface {
+ ParseInfo() ParseInfo
+
+ // Identifies this template and its dependencies.
+ identity.Provider
+}
+
+type InfoManager interface {
+ ParseInfo() ParseInfo
+
+ // Identifies and manages this template and its dependencies.
+ identity.Manager
+}
+
+type defaultInfo struct {
+ identity.Manager
+ parseInfo ParseInfo
+}
+func NewInfo(id identity.Manager, parseInfo ParseInfo) Info {
+ return &defaultInfo{
+ Manager: id,
+ parseInfo: parseInfo,
+ }
+}
+
+func (info *defaultInfo) ParseInfo() ParseInfo {
+ return info.parseInfo
+}
+
+type ParseInfo struct {
// Set for shortcode templates with any {{ .Inner }}
IsInner bool
@@ -26,17 +58,25 @@ type Info struct {
HasReturn bool
// Config extracted from template.
- Config Config
+ Config ParseConfig
}
-func (info Info) IsZero() bool {
+func (info ParseInfo) IsZero() bool {
return info.Config.Version == 0
}
-type Config struct {
+// Info holds some info extracted from a parsed template.
+type Info1 struct {
+}
+
+type ParseConfig struct {
Version int
}
-var DefaultConfig = Config{
+var DefaultParseConfig = ParseConfig{
Version: TemplateVersion,
}
+
+var DefaultParseInfo = ParseInfo{
+ Config: DefaultParseConfig,
+}