1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-22 12:27:02 +00:00

Handlebars support - Embrace the feature request https://github.com/kataras/iris/issues/239

This commit is contained in:
Makis Maropoulos
2016-06-28 12:50:26 +03:00
parent 04dbd0bac9
commit aa319fd8e4
7 changed files with 159 additions and 11 deletions

View File

@@ -26,6 +26,9 @@ const (
// AmberEngine is a Template's config for engine type
// when use this, the templates are eknkc/amber
AmberEngine EngineType = 4
// HandlebarsEngine is a Template's config for engine type
// when use this, the templates are aymerick/raymond
HandlebarsEngine EngineType = 5
// DefaultEngine is the HTMLEngine
DefaultEngine EngineType = HTMLEngine
@@ -115,6 +118,8 @@ type (
Markdown Markdown
// Amber contains specific configs for amber
Amber Amber
// Handlebars contains specific configs for handlebars
Handlebars Handlebars
}
// HTMLTemplate the configs for HTMLEngine
@@ -154,6 +159,12 @@ type (
// Funcs for the html/template result, amber default funcs are not overrided so use it without worries
Funcs template.FuncMap
}
// Handlebars the configs for HandlebarsEngine
Handlebars struct {
// Helpers for Handlebars, you can register your own by raymond.RegisterHelper(name string, a interface{}) or RegisterHelpers(map[string]interface{})
// or just fill this method, do not override it it is not nil by default (because of Iris' helpers (url and urlpath)
Helpers map[string]interface{}
}
)
// DefaultRest returns the default config for rest
@@ -210,6 +221,7 @@ func DefaultTemplate() Template {
Pongo: Pongo{Filters: make(map[string]pongo2.FilterFunction, 0), Globals: make(map[string]interface{}, 0)},
Markdown: Markdown{Sanitize: false},
Amber: Amber{Funcs: template.FuncMap{}},
Handlebars: Handlebars{Helpers: make(map[string]interface{}, 0)},
}
}