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

Nothing special: Linting

This commit is contained in:
Makis Maropoulos
2016-06-03 05:11:50 +03:00
parent 679b707751
commit a337b4768d
20 changed files with 73 additions and 26 deletions

View File

@@ -12,16 +12,19 @@ import (
"github.com/kataras/iris/config"
)
// Engine the amber template engine
type Engine struct {
Config *config.Template
templateCache map[string]*template.Template
mu sync.Mutex
}
// New creates and returns a new amber engine
func New(cfg config.Template) *Engine {
return &Engine{Config: &cfg}
}
// BuildTemplates builds the amber templates
func (e *Engine) BuildTemplates() error {
opt := amber.DirOptions{}
opt.Recursive = true
@@ -67,6 +70,7 @@ func (e *Engine) fromCache(relativeName string) *template.Template {
return nil
}
// ExecuteWriter executes a templates and write its results to the out writer
func (e *Engine) ExecuteWriter(out io.Writer, name string, binding interface{}, layout string) error {
if tmpl := e.fromCache(name); tmpl != nil {
return tmpl.ExecuteTemplate(out, name, binding)

View File

@@ -14,6 +14,7 @@ import (
)
type (
// Engine the html/template engine
Engine struct {
Config *config.Template
Templates *template.Template

View File

@@ -11,7 +11,7 @@ type Engine struct {
*html.Engine
}
// new creates and returns a new JadeEngine with its configs
// New creates and returns a new JadeEngine with its configs
func New(cfg config.Template) *Engine {
underline := &Engine{Engine: html.New(cfg)}

View File

@@ -16,7 +16,9 @@ import (
)
// Supports RAW markdown only, no context binding or layout, to use dynamic markdown with other template engine use the context.Markdown/MarkdownString
type (
// Engine the jade engine
Engine struct {
Config *config.Template
templateCache map[string][]byte
@@ -29,6 +31,7 @@ func New(c config.Template) *Engine {
return &Engine{Config: &c, templateCache: make(map[string][]byte)}
}
// BuildTemplates builds the templates
func (e *Engine) BuildTemplates() error {
if e.Config.Asset == nil || e.Config.AssetNames == nil {
return e.buildFromDir()
@@ -140,7 +143,8 @@ func (e *Engine) fromCache(relativeName string) []byte {
return nil
}
// layout here is unnesecery
// ExecuteWriter executes a templates and write its results to the out writer
// layout here is useless
func (e *Engine) ExecuteWriter(out io.Writer, name string, binding interface{}, layout string) error {
if tmpl := e.fromCache(name); tmpl != nil {
_, err := out.Write(tmpl)