Skip to content

Commit

Permalink
upgrade jet parser to version 6 as requested
Browse files Browse the repository at this point in the history
relative to: #1723
  • Loading branch information
kataras committed Feb 7, 2021
1 parent 36bd452 commit ed33a77
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion _examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
* [Root and Proxy AccessLog instances](logging/request-logger/accesslog-proxy/main.go)
* API Documentation
* [Yaag](apidoc/yaag/main.go)
* [Swagger](https://github.com/iris-contrib/swagger/tree/master/example)
* [Swagger](https://github.com/iris-contrib/swagger/tree/master/_examples/basic)
* [Testing](testing/httptest/main_test.go)
* [Recovery](recover/main.go)
* [Profiling](pprof/main.go)
Expand Down
1 change: 0 additions & 1 deletion _examples/view/template_jet_3/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
)

func main() {

tmpl := iris.Jet("./views", ".jet")
tmpl.Reload(true)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.15

require (
github.com/BurntSushi/toml v0.3.1
github.com/CloudyKit/jet/v5 v5.1.1
github.com/CloudyKit/jet/v6 v6.0.2
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398
github.com/andybalholm/brotli v1.0.1
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible
Expand Down
24 changes: 11 additions & 13 deletions view/jet.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/kataras/iris/v12/context"

"github.com/CloudyKit/jet/v5"
"github.com/CloudyKit/jet/v6"
)

const jetEngineName = "jet"
Expand Down Expand Up @@ -209,14 +209,10 @@ func (l *jetLoader) Open(name string) (io.ReadCloser, error) {
return l.fs.Open(name)
}

// Exists checks if the template name exists by walking the list of template paths
// returns string with the full path of the template and bool true if the template file was found
func (l *jetLoader) Exists(name string) (string, bool) {
if _, err := l.fs.Open(name); err == nil {
return name, true
}

return "", false
// Exists checks if the template name exists by walking the list of template paths.
func (l *jetLoader) Exists(name string) bool {
_, err := l.fs.Open(name)
return err == nil
}

// Load should load the templates from a physical system directory or by an embedded one (assets/go-bindata).
Expand Down Expand Up @@ -250,22 +246,24 @@ func (s *JetEngine) Load() error {
func (s *JetEngine) ParseTemplate(name string, contents string) error {
s.initSet()

_, err := s.Set.LoadTemplate(name, contents)
_, err := s.Set.Parse(name, contents)
return err
}

func (s *JetEngine) initSet() {
s.mu.Lock()
if s.Set == nil {
s.Set = jet.NewHTMLSetLoader(s.loader)
s.Set.Delims(s.left, s.right)
var opts = []jet.Option{
jet.WithDelims(s.left, s.right),
}
if s.developmentMode && !isNoOpFS(s.fs) {
// this check is made to avoid jet's fs lookup on noOp fs (nil passed by the developer).
// This can be produced when nil fs passed
// and only `ParseTemplate` is used.
s.Set.SetDevelopmentMode(true)
opts = append(opts, jet.InDevelopmentMode())
}

s.Set = jet.NewSet(s.loader, opts...)
if s.vars != nil {
for key, value := range s.vars {
s.Set.AddGlobal(key, value)
Expand Down

0 comments on commit ed33a77

Please sign in to comment.