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
🔥 Feature: Add ctx.Bind for set default var map for template engine #1604
Conversation
Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
can render be changed to: Render(*Ctx, io.Writer, string, Map, ...string) error |
why ? |
@liaohongxing why ? |
@ReneWerner87 Because we can easily implement for this feature (set default var map for tempate engine), and also no need to check |
the same topic I had just answered here always having everything and introducing the context here is not really in line with clean code concepts and also makes writing unittests harder and using them outside the fiber context |
I'm using fiber not for api, pure using template engine. Sending session data to template engine in every route is too much work for me. I'll close this pull request. But the feature like in this pull request will be added to fiber or not (maybe in fiber v3)? Because i think feature like this is very important for project that only using template engine. |
do not misunderstand, the "why" referred to the extension/adjustment of the render function with the context (first parameter) the bind method is already useful and good, the only thing that prevents me from merging it is the adjustment of the type in the declaration, don't know if that causes a breaking change and then users have to make adjustments, even though it wouldn't really be necessary |
I missunderstand. I'm not seeing the source code of this repo for long time. I'm very sorry for this. Maybe i drinking too much coffee today, hahaha. Again, i'm so sorry @ReneWerner87 |
is okay, does not matter :D , am always glad about every pull request |
@aztecrabbit can you check my last comments to the pull request, maybe we can make this backward compatible |
I hope to change Render(io.Writer, string, interface(), ...string) error to Render(*Ctx, io.Writer, string, interface(), ...string) error in the next major version Add a Ctx parameter, interface() can be changed to Map, it doesn’t matter This is very helpful for me to write a custom template engine project, mainly to help me inject session, ctx.Local into the template |
@ReneWerner87 The |
fixed with #1754 |
Please provide enough information so that others can review your pull request:
#1536
Hi, i'm changing binding var type from
interface{}
toMap
, is that ok?