use jet v5.0.2 (no breaking changes)

relative to: https://github.com/kataras/iris/pull/1616
This commit is contained in:
Gerasimos (Makis) Maropoulos 2020-09-10 10:12:06 +03:00
parent 62d1185d25
commit 333be428c4
No known key found for this signature in database
GPG Key ID: 5DBE766BD26A54E7
6 changed files with 15 additions and 12 deletions

View File

@ -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` - 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 - 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) - Example has been [updated](https://github.com/kataras/iris/tree/master/_examples/view/template_jet_0)

View File

@ -10,7 +10,7 @@ import (
/* /*
Iris I18n supports text/template inside the translation values. 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() { func main() {
@ -31,8 +31,8 @@ func newApp() *iris.Application {
// like we do here. // like we do here.
// //
// Note that this is only for english, // Note that this is only for english,
// but you can accept the language code // but you can use the "current" locale
// and use a map with dictionaries to // and make a map with dictionaries to
// pluralize words based on the given language. // pluralize words based on the given language.
return pluralize.Pluralize(word, count, true) return pluralize.Pluralize(word, count, true)
}, },
@ -48,5 +48,12 @@ func newApp() *iris.Application {
ctx.WriteString(text) 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 return app
} }

View File

@ -12,6 +12,8 @@ func TestI18nLoaderFuncMap(t *testing.T) {
e := httptest.New(t, app) e := httptest.New(t, app)
e.GET("/").Expect().Status(httptest.StatusOK). e.GET("/").Expect().Status(httptest.StatusOK).
Body().Equal("Hi 2 dogs") 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). e.GET("/").WithHeader("Accept-Language", "el").Expect().Status(httptest.StatusOK).
Body().Equal("Γειά 2 σκυλί") Body().Equal("Γειά 2 σκυλί")
} }

2
go.mod
View File

@ -8,7 +8,7 @@ require (
github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398 github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398
github.com/andybalholm/brotli v1.0.1-0.20200619015827-c3da72aa01ed github.com/andybalholm/brotli v1.0.1-0.20200619015827-c3da72aa01ed
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible 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/eknkc/amber v0.0.0-20171010120322-cdade1c07385
github.com/fatih/structs v1.1.0 github.com/fatih/structs v1.1.0
github.com/gomodule/redigo v1.8.2 github.com/gomodule/redigo v1.8.2

View File

@ -7,7 +7,6 @@ import (
"io/ioutil" "io/ioutil"
"path/filepath" "path/filepath"
"strings" "strings"
"sync"
"text/template" "text/template"
"github.com/kataras/iris/v12/context" "github.com/kataras/iris/v12/context"
@ -266,11 +265,6 @@ type defaultLocale struct {
defaultMessageFunc MessageFunc defaultMessageFunc MessageFunc
} }
type templateKey struct {
Template *template.Template
once *sync.Once
}
func (l *defaultLocale) Index() int { func (l *defaultLocale) Index() int {
return l.index return l.index
} }

View File

@ -11,7 +11,7 @@ import (
"github.com/kataras/iris/v12/context" "github.com/kataras/iris/v12/context"
"github.com/CloudyKit/jet/v4" "github.com/CloudyKit/jet/v5"
) )
const jetEngineName = "jet" const jetEngineName = "jet"