Skip to content

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#8
janklan wants to merge 1 commit intotwigphp:2.xfrom
janklan:2.x

Conversation

@janklan
Copy link
Copy Markdown

@janklan janklan commented Sep 5, 2023

This PR allows passing null value 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_html throws 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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 5, 2023

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!

@github-actions github-actions bot closed this Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant