Allow arbitrary data to be passed to templates
This commit is contained in:
@@ -107,6 +107,9 @@ type WebConfig struct {
|
||||
|
||||
// Defaults to "coreos"
|
||||
Theme string
|
||||
|
||||
// Map of extra values passed into the templates
|
||||
Extra map[string]string
|
||||
}
|
||||
|
||||
func value(val, defaultValue time.Duration) time.Duration {
|
||||
@@ -181,6 +184,7 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
|
||||
issuerURL: c.Issuer,
|
||||
issuer: c.Web.Issuer,
|
||||
theme: c.Web.Theme,
|
||||
extra: c.Web.Extra,
|
||||
}
|
||||
|
||||
static, theme, tmpls, err := loadWebConfig(web)
|
||||
|
@@ -42,6 +42,7 @@ type webConfig struct {
|
||||
issuer string
|
||||
theme string
|
||||
issuerURL string
|
||||
extra map[string]string
|
||||
}
|
||||
|
||||
func join(base, path string) string {
|
||||
@@ -140,6 +141,7 @@ func loadTemplates(c webConfig, templatesDir string) (*templates, error) {
|
||||
"logo": func() string { return c.logoURL },
|
||||
"url": func(s string) string { return join(c.issuerURL, s) },
|
||||
"lower": strings.ToLower,
|
||||
"extra": func(k string) string { return c.extra[k] },
|
||||
}
|
||||
|
||||
tmpls, err := template.New("").Funcs(funcs).ParseFiles(filenames...)
|
||||
|
Reference in New Issue
Block a user