mirror of
https://github.com/kataras/iris.git
synced 2026-01-10 05:25:58 +00:00
formatting
Former-commit-id: 037081db5d6d4434e873ca8b75334ee43e046b6a
This commit is contained in:
@@ -114,7 +114,7 @@ func (s *AmberEngine) loadDirectory() error {
|
||||
funcs[k] = v
|
||||
}
|
||||
|
||||
amber.FuncMap = funcs //set the funcs
|
||||
amber.FuncMap = funcs // set the funcs
|
||||
opt.Ext = extension
|
||||
|
||||
templates, err := amber.CompileDir(dir, opt, amber.DefaultOptions) // this returns the map with stripped extension, we want extension so we copy the map
|
||||
@@ -154,7 +154,7 @@ func (s *AmberEngine) loadAssets() error {
|
||||
virtualDirectory = virtualDirectory[1:]
|
||||
}
|
||||
}
|
||||
amber.FuncMap = funcs //set the funcs
|
||||
amber.FuncMap = funcs // set the funcs
|
||||
|
||||
names := namesFn()
|
||||
|
||||
@@ -177,7 +177,6 @@ func (s *AmberEngine) loadAssets() error {
|
||||
|
||||
name := filepath.ToSlash(rel)
|
||||
tmpl, err := amber.CompileData(buf, name, amber.DefaultOptions)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -199,7 +199,6 @@ func (s *DjangoEngine) RegisterTag(tagName string, fn TagParser) error {
|
||||
//
|
||||
// Returns an error if something bad happens, user is responsible to catch it.
|
||||
func (s *DjangoEngine) Load() error {
|
||||
|
||||
if s.assetFn != nil && s.namesFn != nil {
|
||||
// embedded
|
||||
return s.loadAssets()
|
||||
@@ -237,7 +236,6 @@ func (s *DjangoEngine) loadDirectory() (templateErr error) {
|
||||
// them should be treat as normal.
|
||||
// If is a dir, return immediately (dir is not a valid golang template).
|
||||
if info == nil || info.IsDir() {
|
||||
|
||||
} else {
|
||||
|
||||
rel, err := filepath.Rel(dir, path)
|
||||
@@ -272,7 +270,6 @@ func (s *DjangoEngine) loadDirectory() (templateErr error) {
|
||||
|
||||
// loadAssets loads the templates by binary (go-bindata for embedded).
|
||||
func (s *DjangoEngine) loadAssets() error {
|
||||
|
||||
virtualDirectory, virtualExtension := s.directory, s.extension
|
||||
assetFn, namesFn := s.assetFn, s.namesFn
|
||||
|
||||
|
||||
@@ -118,7 +118,6 @@ func (s *HandlebarsEngine) Load() error {
|
||||
|
||||
// loadDirectory builds the handlebars templates from directory.
|
||||
func (s *HandlebarsEngine) loadDirectory() error {
|
||||
|
||||
// register the global helpers on the first load
|
||||
if len(s.templateCache) == 0 && s.helpers != nil {
|
||||
raymond.RegisterHelpers(s.helpers)
|
||||
@@ -260,7 +259,7 @@ func (s *HandlebarsEngine) ExecuteWriter(w io.Writer, filename string, layout st
|
||||
binding := bindingData
|
||||
if isLayout {
|
||||
var context map[string]interface{}
|
||||
if m, is := binding.(map[string]interface{}); is { //handlebars accepts maps,
|
||||
if m, is := binding.(map[string]interface{}); is { // handlebars accepts maps,
|
||||
context = m
|
||||
} else {
|
||||
return fmt.Errorf("Please provide a map[string]interface{} type as the binding instead of the %#v", binding)
|
||||
@@ -279,7 +278,6 @@ func (s *HandlebarsEngine) ExecuteWriter(w io.Writer, filename string, layout st
|
||||
}
|
||||
|
||||
res, err := tmpl.Exec(binding)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
12
view/html.go
12
view/html.go
@@ -269,10 +269,10 @@ func (s *HTMLEngine) loadDirectory() error {
|
||||
templateErr = err
|
||||
return err
|
||||
}
|
||||
//s.mu.Lock()
|
||||
// s.mu.Lock()
|
||||
// Add our funcmaps.
|
||||
_, err = tmpl.Funcs(emptyFuncs).Funcs(s.funcs).Parse(contents)
|
||||
//s.mu.Unlock()
|
||||
// s.mu.Unlock()
|
||||
if err != nil {
|
||||
templateErr = err
|
||||
return err
|
||||
@@ -409,10 +409,10 @@ func (s *HTMLEngine) layoutFuncsFor(name string, binding interface{}) {
|
||||
}
|
||||
return "", nil
|
||||
},
|
||||
//partial related to current page,
|
||||
//it would be easier for adding pages' style/script inline
|
||||
//for example when using partial_r '.script' in layout.html
|
||||
//templates/users/index.html would load templates/users/index.script.html
|
||||
// partial related to current page,
|
||||
// it would be easier for adding pages' style/script inline
|
||||
// for example when using partial_r '.script' in layout.html
|
||||
// templates/users/index.html would load templates/users/index.script.html
|
||||
"partial_r": func(partialName string) (template.HTML, error) {
|
||||
ext := filepath.Ext(name)
|
||||
root := name[:len(name)-len(ext)]
|
||||
|
||||
@@ -37,9 +37,7 @@ func (v *View) Len() int {
|
||||
return len(v.engines)
|
||||
}
|
||||
|
||||
var (
|
||||
errNoViewEngineForExt = errors.New("no view engine found for '%s'")
|
||||
)
|
||||
var errNoViewEngineForExt = errors.New("no view engine found for '%s'")
|
||||
|
||||
// ExecuteWriter calls the correct view Engine's ExecuteWriter func
|
||||
func (v *View) ExecuteWriter(w io.Writer, filename string, layout string, bindingData interface{}) error {
|
||||
|
||||
Reference in New Issue
Block a user