Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctx.ViewData not work with JetEngine #1330

Closed
Dexus opened this issue Aug 7, 2019 · 2 comments
Closed

ctx.ViewData not work with JetEngine #1330

Dexus opened this issue Aug 7, 2019 · 2 comments

Comments

@Dexus
Copy link

Dexus commented Aug 7, 2019

Hi @kataras,

I'm testing the JetEngine as a view. Unfortunately, the default ctx.ViewData is not passed to JetEngine. In my opinion this would be a Braking Change.

Wouldn't it make sense to make this usable in the same way as with the other engines?

Example:

ctx.ViewData("demo", 123)
ctx.View("pages/index.jet")

Returns in Logs: [ERRO] 2019/08/07 12:38 Jet Runtime Error("pages/index.jet":4): identifier "demo" is not available in the current scope map[]

@kataras
Copy link
Owner

kataras commented Aug 7, 2019

Hello @Dexus,

I agree with you.

To set runtime template variables use the jet.AddRuntimeVars(ctx iris.Context, vars jet.JetRuntimeVars) (VarMap)

EDIT:

Give me some time, I may need to check if the data is map and if so then somehow convert these to VarMap and pass them, I think I already tried this and it failed but let me try something else now.

@kataras kataras closed this as completed in fe9bfbc Aug 9, 2019
@kataras
Copy link
Owner

kataras commented Aug 9, 2019

@Dexus, it's fixed. Please test it by yourself, example updated as well.

ctx.ViewData("showingAllDone", true)
ctx.ViewData("title", "Todos - All Done")
// Key does not actual matter at all here.
// However, you can enable it for better performance.
// In order to enable key mapping for
// jet specific renderer and ranger types
// you have to initialize the View Engine
// with `tmpl.DisableViewDataTypeCheck("_jet")`.
//
// Defaults to type checks, empty key.
ctx.ViewData("_jet", (&doneTODOs{}).New(todos))
ctx.View("todos/index.jet")

github-actions bot pushed a commit to goproxies/github.com-kataras-iris that referenced this issue Jul 27, 2020
Former-commit-id: 221e01638b671586cdab2b84518bd6a1c8d07bda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants