Silly idea I had

This commit is contained in:
2024-12-09 23:32:12 -05:00
parent 8084b7749a
commit a2680c40d2
2 changed files with 25 additions and 9 deletions

View File

@@ -5,6 +5,23 @@ import "html/template"
// Provider is an object which provides extra functionality to an environment.
type Provider any
// Configurable is an object that can be configured according to metadata.
type Configurable interface {
Provider
// Configure uses config to configure the object. It must not modify
// config. Keys are namespaced with a '.' and are written in kebab case.
Configure (config Meta) error
}
// ConfigProcessor is an object that can alter the environment configuration
// before other providers are configured in order to provide a sort of macro
// system.
type ConfigProcessor interface {
// ProcessConfig analyzes and makes necessary changes to config. Unlike
// Configurable.Configure, it can modify config.
ProcessConfig (config Meta) error
}
// FuncProvider provides a template.FuncMap.
type FuncProvider interface {
Provider
@@ -21,11 +38,3 @@ type FuncProviderFor interface {
// may return nil, in which case its result is simply not considered.
FuncMapFor (*Document) template.FuncMap
}
// Configurable is an object that can be configured according to metadata.
type Configurable interface {
Provider
// Configure uses config to configure the object. It must not modify
// config. Keys are namespaced with a '.' and are written in kebab case.
Configure (config Meta) error
}