mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02: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:
@@ -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,
|
||||
}
|
||||
|
Reference in New Issue
Block a user