diff --git a/template/engine.go b/template/engine.go index 55eb7e31..3436de7a 100644 --- a/template/engine.go +++ b/template/engine.go @@ -98,13 +98,13 @@ func (e *Engine) ParseTemplates() error { } // Render process a template. -func (e *Engine) Render(name, language string, data interface{}) []byte { +func (e *Engine) Render(name string, data map[string]interface{}) []byte { tpl, ok := e.templates[name] if !ok { logger.Fatal("[Template] The template %s does not exists", name) } - printer := locale.NewPrinter(language) + printer := locale.NewPrinter(data["language"].(string)) // Functions that need to be declared at runtime. tpl.Funcs(template.FuncMap{ diff --git a/template/functions.go b/template/functions.go index a38893e0..d4ca80ed 100644 --- a/template/functions.go +++ b/template/functions.go @@ -75,6 +75,9 @@ func (f *funcMap) Map() template.FuncMap { "contains": func(str, substr string) bool { return strings.Contains(str, substr) }, + "replace": func(str, old string, new string) string { + return strings.Replace(str, old, new, 1) + }, "isodate": func(ts time.Time) string { return ts.Format("2006-01-02 15:04:05") }, diff --git a/template/templates/common/layout.html b/template/templates/common/layout.html index 7589847c..efdedbb5 100644 --- a/template/templates/common/layout.html +++ b/template/templates/common/layout.html @@ -1,6 +1,6 @@ {{ define "base" }} - +