diff --git a/ace/ace.go b/ace/ace.go index d68dcb2..2254c5b 100644 --- a/ace/ace.go +++ b/ace/ace.go @@ -27,6 +27,8 @@ type Engine struct { extension string // layout variable name that incapsulates the template layout string + // determines if the engine parsed all templates + loaded bool // reload on each render reload bool // debug prints the parsed templates @@ -187,6 +189,8 @@ func (e *Engine) Load() error { } return err } + // notify engine that we parsed all templates + e.loaded = true if e.fileSystem != nil { return utils.Walk(e.fileSystem, e.directory, walkFn) } @@ -196,7 +200,7 @@ func (e *Engine) Load() error { // Execute will render the template by name func (e *Engine) Render(out io.Writer, template string, binding interface{}, layout ...string) error { // reload the views - if e.reload { + if !e.loaded || e.reload { ace.FlushCache() if err := e.Load(); err != nil { return err diff --git a/amber/amber.go b/amber/amber.go index 7a009ec..70b5d94 100644 --- a/amber/amber.go +++ b/amber/amber.go @@ -24,6 +24,8 @@ type Engine struct { extension string // layout variable name that incapsulates the template layout string + // determines if the engine parsed all templates + loaded bool // reload on each render reload bool // debug prints the parsed templates @@ -176,7 +178,8 @@ func (e *Engine) Load() error { } return err } - + // notify engine that we parsed all templates + e.loaded = true if e.fileSystem != nil { return utils.Walk(e.fileSystem, e.directory, walkFn) } @@ -185,7 +188,7 @@ func (e *Engine) Load() error { // Render will execute the template name along with the given values. func (e *Engine) Render(out io.Writer, template string, binding interface{}, layout ...string) error { - if e.reload { + if !e.loaded || e.reload { if err := e.Load(); err != nil { return err } diff --git a/django/django.go b/django/django.go index 80a0bc7..f7a1dea 100644 --- a/django/django.go +++ b/django/django.go @@ -9,7 +9,7 @@ import ( "strings" "sync" - "github.com/flosch/pongo2/v4" + "github.com/flosch/pongo2" "github.com/gofiber/fiber/v2" "github.com/gofiber/template/utils" ) @@ -27,6 +27,8 @@ type Engine struct { extension string // layout variable name that incapsulates the template layout string + // determines if the engine parsed all templates + loaded bool // reload on each render reload bool // debug prints the parsed templates @@ -165,6 +167,8 @@ func (e *Engine) Load() error { } return err } + // notify engine that we parsed all templates + e.loaded = true if e.fileSystem != nil { return utils.Walk(e.fileSystem, e.directory, walkFn) } @@ -194,7 +198,7 @@ func getPongoBinding(binding interface{}) pongo2.Context { // Render will render the template by name func (e *Engine) Render(out io.Writer, template string, binding interface{}, layout ...string) error { - if e.reload { + if !e.loaded || e.reload { if err := e.Load(); err != nil { return err } diff --git a/go.mod b/go.mod index cf95443..daf82d4 100644 --- a/go.mod +++ b/go.mod @@ -9,8 +9,8 @@ require ( github.com/aymerick/raymond v2.0.2+incompatible github.com/cbroglie/mustache v1.2.0 github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 - github.com/flosch/pongo2/v4 v4.0.0 - github.com/gofiber/fiber/v2 v2.0.1 + github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3 + github.com/gofiber/fiber/v2 v2.0.2 github.com/mattn/go-slim v0.0.0-20200618151855-bde33eecb5ee github.com/valyala/bytebufferpool v1.0.0 github.com/yosssi/ace v0.0.5 diff --git a/go.sum b/go.sum index e479c79..94f3a81 100644 --- a/go.sum +++ b/go.sum @@ -72,8 +72,8 @@ github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZi github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= -github.com/flosch/pongo2/v4 v4.0.0 h1:6eZe8NSNxtTTGwXgJqqXiiLEDAj7CvkwiYrZFQRW6cQ= -github.com/flosch/pongo2/v4 v4.0.0/go.mod h1:B5ObFANs/36VwxxlgKpdchIJHMvHB562PW+BWPhwZD8= +github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3 h1:fmFk0Wt3bBxxwZnu48jqMdaOR/IZ4vdtJFuaFV8MpIE= +github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3/go.mod h1:bJWSKrZyQvfTnb2OudyUjurSG4/edverV7n82+K3JiM= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -113,8 +113,8 @@ github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b h1:khEcpUM4yFcxg4 github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gofiber/fiber/v2 v2.0.1 h1:82Sw1SyHrEaKLYdXbNJGzI/t2okEeDIuw9nJGKpQmaI= -github.com/gofiber/fiber/v2 v2.0.1/go.mod h1:GeIpT8VILgZt3Tn6gATjwb39Ff8OdM0qnZ2grAA0Vts= +github.com/gofiber/fiber/v2 v2.0.2 h1:Zet9qNptQkhrLZhWBHZQNjeSnokp8xyiGQp4Je0p3yk= +github.com/gofiber/fiber/v2 v2.0.2/go.mod h1:GeIpT8VILgZt3Tn6gATjwb39Ff8OdM0qnZ2grAA0Vts= github.com/gofrs/flock v0.7.1 h1:DP+LD/t0njgoPBvT5MJLeliUIVQR03hiKR6vezdwHlc= github.com/gofrs/flock v0.7.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -539,9 +539,11 @@ golang.org/x/tools v0.0.0-20200422022333-3d57cf2e726e/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200428185508-e9a00ec82136/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200519015757-0d0afa43d58a/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200625211823-6506e20df31f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200702044944-0cc1aa72b347 h1:/e4fNMHdLn7SQSxTrRZTma2xjQW6ELdxcnpqMhpo9X4= golang.org/x/tools v0.0.0-20200702044944-0cc1aa72b347/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= @@ -573,25 +575,36 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +mvdan.cc/gofumpt v0.0.0-20200513141252-abc0db2c416a h1:TTEzidAa7rn93JGy1ACigx6o9VcsRLKG7qICdErmvUs= mvdan.cc/gofumpt v0.0.0-20200513141252-abc0db2c416a/go.mod h1:4q/PlrZKQLU5MowSvCKM3U4xJUPtJ8vKWx7vsWFJ3MI= +mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed h1:WX1yoOaKQfddO/mLzdV4wptyWgoH/6hwLs7QHTixo0I= mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= +mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b h1:DxJ5nJdkhDlLok9K6qO+5290kphDJbHOQO1DFFFTeBo= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= +mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f h1:Cq7MalBHYACRd6EesksG1Q8EoIAKOsiZviGKbOLIej4= mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4 h1:JPJh2pk3+X4lXAkZIk2RuE/7/FoK9maXw+TNPJhVS/c= sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= diff --git a/handlebars/handlebars.go b/handlebars/handlebars.go index 6e47042..e71d489 100644 --- a/handlebars/handlebars.go +++ b/handlebars/handlebars.go @@ -23,6 +23,8 @@ type Engine struct { extension string // layout variable name that incapsulates the template layout string + // determines if the engine parsed all templates + loaded bool // reload on each render reload bool // debug prints the parsed templates @@ -170,12 +172,14 @@ func (e *Engine) Load() (err error) { e.Templates[i].RegisterPartialTemplate(n, t) } } + // notify engine that we parsed all templates + e.loaded = true return } // Execute will render the template by name func (e *Engine) Render(out io.Writer, template string, binding interface{}, layout ...string) error { - if e.reload { + if !e.loaded || e.reload { if err := e.Load(); err != nil { return err } diff --git a/html/html.go b/html/html.go index 33ed77c..b06c00c 100644 --- a/html/html.go +++ b/html/html.go @@ -26,6 +26,8 @@ type Engine struct { extension string // layout variable name that incapsulates the template layout string + // determines if the engine parsed all templates + loaded bool // reload on each render reload bool // debug prints the parsed templates @@ -170,7 +172,8 @@ func (e *Engine) Load() error { } return err } - + // notify engine that we parsed all templates + e.loaded = true if e.fileSystem != nil { return utils.Walk(e.fileSystem, e.directory, walkFn) } @@ -179,7 +182,7 @@ func (e *Engine) Load() error { // Render will execute the template name along with the given values. func (e *Engine) Render(out io.Writer, template string, binding interface{}, layout ...string) error { - if e.reload { + if !e.loaded || e.reload { if err := e.Load(); err != nil { return err } diff --git a/jet/jet.go b/jet/jet.go index 0d3b512..baac05c 100644 --- a/jet/jet.go +++ b/jet/jet.go @@ -28,6 +28,8 @@ type Engine struct { extension string // layout variable name that incapsulates the template layout string + // determines if the engine parsed all templates + loaded bool // reload on each render reload bool // debug prints the parsed templates @@ -177,6 +179,8 @@ func (e *Engine) Load() error { } return err } + // notify engine that we parsed all templates + e.loaded = true if e.fileSystem != nil { return utils.Walk(e.fileSystem, e.directory, walkFn) } @@ -185,7 +189,7 @@ func (e *Engine) Load() error { // Execute will render the template by name func (e *Engine) Render(out io.Writer, template string, binding interface{}, layout ...string) error { - if e.reload { + if !e.loaded || e.reload { if err := e.Load(); err != nil { return err } diff --git a/mustache/mustache.go b/mustache/mustache.go index af84748..a689905 100644 --- a/mustache/mustache.go +++ b/mustache/mustache.go @@ -24,6 +24,8 @@ type Engine struct { extension string // layout variable name that incapsulates the template layout string + // determines if the engine parsed all templates + loaded bool // reload on each render reload bool // debug prints the parsed templates @@ -144,6 +146,8 @@ func (e *Engine) Load() error { } return err } + // notify engine that we parsed all templates + e.loaded = true if e.fileSystem != nil { return utils.Walk(e.fileSystem, e.directory, walkFn) } @@ -152,7 +156,7 @@ func (e *Engine) Load() error { // Execute will render the template by name func (e *Engine) Render(out io.Writer, template string, binding interface{}, layout ...string) error { - if e.reload { + if !e.loaded || e.reload { if err := e.Load(); err != nil { return err } diff --git a/pug/pug.go b/pug/pug.go index 8a6c379..55ee365 100644 --- a/pug/pug.go +++ b/pug/pug.go @@ -28,6 +28,8 @@ type Engine struct { extension string // layout variable name that incapsulates the template layout string + // determines if the engine parsed all templates + loaded bool // reload on each render reload bool // debug prints the parsed templates @@ -177,7 +179,8 @@ func (e *Engine) Load() error { } return err } - + // notify engine that we parsed all templates + e.loaded = true if e.fileSystem != nil { return utils.Walk(e.fileSystem, e.directory, walkFn) } @@ -186,7 +189,7 @@ func (e *Engine) Load() error { // Execute will render the template by name func (e *Engine) Render(out io.Writer, template string, binding interface{}, layout ...string) error { - if e.reload { + if !e.loaded || e.reload { if err := e.Load(); err != nil { return err } diff --git a/slim/slim.go b/slim/slim.go index ce8b0c4..fef6e69 100644 --- a/slim/slim.go +++ b/slim/slim.go @@ -28,6 +28,8 @@ type Engine struct { extension string // layout variable name that incapsulates the template layout string + // determines if the engine parsed all templates + loaded bool // reload on each render reload bool // debug prints the parsed templates @@ -163,6 +165,8 @@ func (e *Engine) Load() error { } return err } + // notify engine that we parsed all templates + e.loaded = true if e.fileSystem != nil { return utils.Walk(e.fileSystem, e.directory, walkFn) } @@ -171,7 +175,7 @@ func (e *Engine) Load() error { // Execute will render the template by name func (e *Engine) Render(out io.Writer, template string, binding interface{}, layout ...string) error { - if e.reload { + if !e.loaded || e.reload { if err := e.Load(); err != nil { return err }