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
add RenderWith #773
add RenderWith #773
Conversation
RenderWith will is not panic while render is fail.
Codecov Report
@@ Coverage Diff @@
## develop #773 +/- ##
=========================================
- Coverage 96.17% 93.18% -3%
=========================================
Files 16 15 -1
Lines 1413 1291 -122
=========================================
- Hits 1359 1203 -156
- Misses 43 76 +33
- Partials 11 12 +1
Continue to review full report at Codecov.
|
Please provide testing code. |
I know this will break backwards compatibility so isn't likely to get renamed, but shouldn't RenderWith technicall be called Render as it returns an error, and Render then called MustRender (since it panics) and that seems to be the naming convention in Go for methods that panic. But this is the next best thing, thanks, I really needed a render method that doesn't panic. I also had an issue that the Instance method panics rather than return an error, which was a bit annoying when I was building a custom renderer a while back, issue #678 described that. |
add unit test of Context.RenderWith()
I add test code |
I know I am not one of the Gin contributors so I don't really have say in this, so merge it if you want, but... I still stand by the fact that these methods are named incorrectly, Render should become MustRender since it's panics. RenderWith is a terrible name as it indicates you are rendering with something being passed to it, possibly a context or something. I personally would actually call RenderWith just Render, and call Render MustRender. I would do so in v2, breaking backwards compatibility for the greater good. |
@javierprovecho @tboerger What do you guys think about naming? |
Alternatively, #952 changes |
@runner-mei please re-commit the pull request to |
@robvdl |
TryRender |
ref: |
@thinkerou because "render with" sounds like you are rendering with ... something ... like a context, the name name does not describe what it really does which is that it does a render but does panic on error. I don't think you should use ShouldRender or ShouldBind either because the normal naming convention in Go is to use MustRender when something panics, and Render it if doesn't. It seems that pre-pending Must is the usual convention used. I personally think it's much better to use the naming convention the Go community is already using rather than use something different. |
RenderWith will is not panic while render is fail.