Skip to content

Commit

Permalink
Merge pull request #7 from Fenny/master
Browse files Browse the repository at this point in the history
Make Parse Public
  • Loading branch information
Fenny committed Jun 3, 2020
2 parents cdd9840 + 4c57d7f commit fd53cec
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 22 deletions.
6 changes: 3 additions & 3 deletions ace/ace.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ func New(directory, extension string, funcmap ...map[string]interface{}) *Engine
if len(funcmap) > 0 {
engine.funcs = funcmap[0]
}
if err := engine.load(); err != nil {
if err := engine.Parse(); err != nil {
log.Fatalf("ace.New(): %v", err)
}
return engine
}

// load parses the templates to the engine.
func (e *Engine) load() error {
// Parse parses the templates to the engine.
func (e *Engine) Parse() error {
// Loop trough each directory and register template files
err := filepath.Walk(e.directory, func(path string, info os.FileInfo, err error) error {
path = strings.TrimRight(path, ".")
Expand Down
6 changes: 3 additions & 3 deletions amber/amber.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ func New(directory, extension string, funcmap ...map[string]interface{}) *Engine
if len(funcmap) > 0 {
amber.FuncMap = funcmap[0]
}
if err := engine.load(); err != nil {
if err := engine.Parse(); err != nil {
log.Fatalf("amber.New(): %v", err)
}
return engine
}

// load parses the templates to the engine.
func (e *Engine) load() error {
// Parse parses the templates to the engine.
func (e *Engine) Parse() error {
// Loop trough each directory and register template files
err := filepath.Walk(e.directory, func(path string, info os.FileInfo, err error) error {
// Return error if exist
Expand Down
6 changes: 3 additions & 3 deletions django/django.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func New(directory, extension string, funcmap ...map[string]interface{}) *Engine
if len(funcmap) > 0 {
// pongo2.RegisterFilter()
}
if err := engine.load(); err != nil {
if err := engine.Parse(); err != nil {
log.Fatalf("django.New(): %v", err)
}
return engine
}

// Load parses the templates to the engine.
func (e *Engine) load() error {
// Parse parses the templates to the engine.
func (e *Engine) Parse() error {
// Loop trough each directory and register template files
err := filepath.Walk(e.directory, func(path string, info os.FileInfo, err error) error {
// Return error if exist
Expand Down
6 changes: 3 additions & 3 deletions handlebars/handlebars.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func New(directory, extension string, funcmap ...map[string]interface{}) *Engine
if len(funcmap) > 0 {
raymond.RegisterHelpers(funcmap[0])
}
if err := engine.load(); err != nil {
if err := engine.Parse(); err != nil {
log.Fatalf("handlebars.New(): %v", err)
}
return engine
}

// Load parses the templates to the engine.
func (e *Engine) load() error {
// Parse parses the templates to the engine.
func (e *Engine) Parse() error {
// Loop trough each directory and register template files
err := filepath.Walk(e.directory, func(path string, info os.FileInfo, err error) error {
// Return error if exist
Expand Down
6 changes: 3 additions & 3 deletions html/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ func New(directory, extension string, funcmap ...map[string]interface{}) *Engine
if len(funcmap) > 0 {
engine.Templates.Funcs(funcmap[0])
}
if err := engine.load(); err != nil {
if err := engine.Parse(); err != nil {
log.Fatalf("html.New(): %v", err)
}
return engine
}

// load parses the templates to the engine.
func (e *Engine) load() error {
// Parse parses the templates to the engine.
func (e *Engine) Parse() error {
// Loop trough each directory and register template files
err := filepath.Walk(e.directory, func(path string, info os.FileInfo, err error) error {
// Return error if exist
Expand Down
11 changes: 10 additions & 1 deletion jet/jet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package jet

import (
"io"
"log"

"github.com/CloudyKit/jet"
)
Expand All @@ -19,16 +20,24 @@ func New(directory, extension string, funcmap ...map[string]interface{}) *Engine
engine := &Engine{
directory: directory,
extension: extension,
Templates: jet.NewHTMLSet(directory),
}
if len(funcmap) > 0 {
for key, value := range funcmap[0] {
engine.Templates.AddGlobal(key, value)
}
}
if err := engine.Parse(); err != nil {
log.Fatalf("jet.New(): %v", err)
}
return engine
}

// Parse parses the templates to the engine.
func (e *Engine) Parse() error {
e.Templates = jet.NewHTMLSet(e.directory)
return nil
}

func getJetBinding(binding interface{}) jet.VarMap {
if binding == nil {
return nil
Expand Down
6 changes: 3 additions & 3 deletions mustache/mustache.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func New(directory, extension string, funcmap ...map[string]interface{}) *Engine
if len(funcmap) > 0 {
//raymond.RegisterHelpers(funcmap[0])
}
if err := engine.load(); err != nil {
if err := engine.Parse(); err != nil {
log.Fatalf("mustache.New(): %v", err)
}
return engine
}

// Load parses the templates to the engine.
func (e *Engine) load() error {
// Parse parses the templates to the engine.
func (e *Engine) Parse() error {
// Loop trough each directory and register template files
err := filepath.Walk(e.directory, func(path string, info os.FileInfo, err error) error {
// Return error if exist
Expand Down
6 changes: 3 additions & 3 deletions pug/pug.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func New(directory, extension string, funcmap ...map[string]interface{}) *Engine
if len(funcmap) > 0 {
engine.Templates.Funcs(funcmap[0])
}
if err := engine.load(); err != nil {
if err := engine.Parse(); err != nil {
log.Fatalf("pug.New(): %v", err)
}
return engine
}

// load parses the templates to the engine.
func (e *Engine) load() error {
// Parse parses the templates to the engine.
func (e *Engine) Parse() error {
// Loop trough each directory and register template files
err := filepath.Walk(e.directory, func(path string, info os.FileInfo, err error) error {
// Return error if exist
Expand Down

0 comments on commit fd53cec

Please sign in to comment.