Accept null in markdown_to_html input#8
Closed
janklan wants to merge 1 commit intotwigphp:2.xfrom
janklan:2.x
Closed
Accept null in markdown_to_html input#8janklan wants to merge 1 commit intotwigphp:2.xfrom janklan:2.x
janklan wants to merge 1 commit intotwigphp:2.xfrom
janklan:2.x
Conversation
|
Thanks for your pull request! We love contributions. However, you should instead open a pull request on the main repository: https://github.com/twigphp/Twig This repository is what we call a "subtree split": a read-only subset of that main repository. We're looking forward to your PR there! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR allows passing
nullvalue to the markdown converter, returning an empty string instead of throwing an error.Every significant Doctrine entity in my app has an optional Description field. I always push that value through the Markdown filter, and so I find myself always writing
{% if entity.description %}{{ entity.description|markdown_to_html }}{% endif %}The only reason for doing so is the fact
markdown_to_htmlthrows an error when receiving a null value. I think returning an empty value instead of a fatal error is a sane(r) default behaviour, hence this PR.Thanks for reading.