Skip to content

Commit

Permalink
use jet v5.0.2 (no breaking changes)
Browse files Browse the repository at this point in the history
relative to: #1616
  • Loading branch information
kataras committed Sep 10, 2020
1 parent 62d1185 commit 333be42
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ var dirOpts = iris.DirOptions{
}
```

- Update jet parser to v4.0.2, closes [#1551](https://github.com/kataras/iris/issues/1551). It contains two breaking changes by its author:
- Update jet parser to v5.0.2, closes [#1551](https://github.com/kataras/iris/issues/1551). It contains two breaking changes by its author:
- Relative paths on `extends, import, include...` tmpl functions, e.g. `{{extends "../layouts/application.jet"}}` instead of `layouts/application.jet`
- the new [jet.Ranger](https://github.com/CloudyKit/jet/pull/165) interface now requires a `ProvidesIndex() bool` method too
- Example has been [updated](https://github.com/kataras/iris/tree/master/_examples/view/template_jet_0)
Expand Down
13 changes: 10 additions & 3 deletions _examples/i18n/i18n-template/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

/*
Iris I18n supports text/template inside the translation values.
Follow this tutorial to learn how to use that feature.
Follow this example to learn how to use that feature.
*/

func main() {
Expand All @@ -31,8 +31,8 @@ func newApp() *iris.Application {
// like we do here.
//
// Note that this is only for english,
// but you can accept the language code
// and use a map with dictionaries to
// but you can use the "current" locale
// and make a map with dictionaries to
// pluralize words based on the given language.
return pluralize.Pluralize(word, count, true)
},
Expand All @@ -48,5 +48,12 @@ func newApp() *iris.Application {
ctx.WriteString(text)
})

app.Get("/singular", func(ctx iris.Context) {
text := ctx.Tr("HiDogs", iris.Map{
"count": 1,
}) // prints "Hi 1 dog".
ctx.WriteString(text)
})

return app
}
2 changes: 2 additions & 0 deletions _examples/i18n/i18n-template/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ func TestI18nLoaderFuncMap(t *testing.T) {
e := httptest.New(t, app)
e.GET("/").Expect().Status(httptest.StatusOK).
Body().Equal("Hi 2 dogs")
e.GET("/singular").Expect().Status(httptest.StatusOK).
Body().Equal("Hi 1 dog")
e.GET("/").WithHeader("Accept-Language", "el").Expect().Status(httptest.StatusOK).
Body().Equal("Γειά 2 σκυλί")
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398
github.com/andybalholm/brotli v1.0.1-0.20200619015827-c3da72aa01ed
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible
github.com/dgraph-io/badger/v2 v2.2007.1
github.com/dgraph-io/badger/v2 v2.2007.2
github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385
github.com/fatih/structs v1.1.0
github.com/gomodule/redigo v1.8.2
Expand Down
6 changes: 0 additions & 6 deletions i18n/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"io/ioutil"
"path/filepath"
"strings"
"sync"
"text/template"

"github.com/kataras/iris/v12/context"
Expand Down Expand Up @@ -266,11 +265,6 @@ type defaultLocale struct {
defaultMessageFunc MessageFunc
}

type templateKey struct {
Template *template.Template
once *sync.Once
}

func (l *defaultLocale) Index() int {
return l.index
}
Expand Down
2 changes: 1 addition & 1 deletion view/jet.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

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

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

const jetEngineName = "jet"
Expand Down

0 comments on commit 333be42

Please sign in to comment.