-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
🤗 [Question]: V3: ctx.Render not longer accepts types other than fibre.Map #3219
Comments
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
In Fiber v2 it accepts any but it asserts the bind parameter into Map, so if the argument's actual type is not fiber.Map then it's not used at all. In v3, we made it Map and removed assertion step. Therefore, it should not really be changing any functionality or behavior. Can you explain whether it changes anything @m13t ? |
Thanks for the response @efectn. So the reason I raise this is that all the template engines accept structs or maps as bind parameters to be used in templates, so this feels like a big change to force consumers of Fiber v3 to have to convert structs to maps for passing to templates. I can see in the code for V2 that it only sets bind to a map if there bind is nil and it must be a map in order to pass locals from the request context to the template. However, passing structs to the template engine works as expected in V2, structured properties are able to be used in templates. So just to clarify, this is quite a significant change to template functionality in V3, hence the question why the decision was made to change this? See the following: Lines 1583 to 1585 in 6968d51
Line 1603 in 6968d51
|
Thanks for the clarification; now, i get you. I don't really remember the historical reason behind this change despite the fact that the change was commited by me :D I think you are right, this needs to be reverted as most of the template engines also support. What do you think @ReneWerner87 @gaby |
Question Description
I'm curious why the API for the fiber context no longer accepts the
any
type for render binding parameters and only acceptsfiber.Map
?The abstracted template engines still support bind parameters allowing the passing of structs (or indeed a map) so I'm wondering if there are plans to change the template engine implementation to match too?
I feel like migrating from V2 to V3 with this change will result in a lot of unnecessary refactoring for users where structs that are used throughout an application lifecycle as well as being passed to templates, now need to be converted to a map structure.
Code Snippet (optional)
No response
Checklist:
The text was updated successfully, but these errors were encountered: