1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-08 12:31:58 +00:00

New: i18n pluralization and variables support and more...

fixes: #1649, #1648, #1641, #1650

relative to: #1597
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-09-29 19:19:19 +03:00
parent f224ded740
commit 4065819688
63 changed files with 2054 additions and 684 deletions

View File

@@ -14,6 +14,7 @@ import (
// HTMLEngine contains the html view engine structure.
type HTMLEngine struct {
name string // the view engine's name, can be HTML, Ace or Pug.
// the file system to load from.
fs http.FileSystem
// files configuration
@@ -81,6 +82,7 @@ var emptyFuncs = template.FuncMap{
// HTML(AssetFile(), ".html") for embedded data.
func HTML(fs interface{}, extension string) *HTMLEngine {
s := &HTMLEngine{
name: "HTML",
fs: getFS(fs),
rootDir: "/",
extension: extension,
@@ -102,7 +104,13 @@ func (s *HTMLEngine) RootDir(root string) *HTMLEngine {
return s
}
// Name returns the engine's name.
func (s *HTMLEngine) Name() string {
return s.name
}
// Ext returns the file extension which this view engine is responsible to render.
// If the filename extension on ExecuteWriter is empty then this is appended.
func (s *HTMLEngine) Ext() string {
return s.extension
}
@@ -409,7 +417,7 @@ func (s *HTMLEngine) ExecuteWriter(w io.Writer, name string, layout string, bind
if layout = getLayout(layout, s.layout); layout != "" {
lt := s.Templates.Lookup(layout)
if lt == nil {
return ErrNotExist{name, true}
return ErrNotExist{layout, true}
}
s.layoutFuncsFor(lt, name, bindingData)