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
content_for is not working as described when content is not set #9360
Comments
If that's define in the doc like that, I think that's a bug/regression. Good finding! Would you mind submitting a failing test case, or even better a fix for this? Thank! |
I would also trust the documentation if this was added to the docs it once was a use-case. @killthekitten I could take a look and submit a PR to solve the problem. Let me know if you are not working on it. |
@killthekitten I did not look into the source yet... but the problem seems straight forward. You could look what commit added the example in the documentation and take a look at how the code looked back then to ensure if it worked once. Then write a failing test-case and as last step change the code so that it passes your newly written test and all others on AP/AV. |
Yeah, I'm pretty sure it was overlooked when we introduced SafeBuffer. |
Sad, this PR breaks many tests. Didn't run the full suite before commit. |
Fix for #9360 content_for regression
Hey, it is broken again in 3.2.19 :) and defaults to an empty string |
@sadfuzzy and did you check if tests are also failing (probably they don't, but can you provide us with a failing case?)? |
Following this example from documentation,
content_for
can be used as a part of boolean statement:But it does not behave as described.
content_for
output is wrapped withActiveSupport::SafeBuffer
which castsnil
value to an empty string instead of just returningnil
.To be clear, I expect
content_for
to returnnil
if no content is set. Here is my case:And it does not work as expected. My current workaround:
Do we need to update example? Or is it a bug?
The text was updated successfully, but these errors were encountered: