IMHO opinion this filter is needed, however it should target Twig specifically and properly process HTML entities.
In its current form, the result is the same as
|striptags|trim
.For example, take a field value of "Twelve O'Clock".
Both
|striptags|trim
and|remove_html_comments
produce the same result:Twelve O'Clock
I suggest 2 changes to make this filter worthwhile in its own right:
- Rename it to
|strip_twig_debug
or
|remove_twig_debug</li> <li>Process HTML entities</li> </ol> If processing HTML entities feels too invasive, you could always pass an optional argument allowing people to prevent HTML entity processing. Currently, the only viable option is the <a href="https://www.drupal.org/project/twig_htmlspecialchars_decode">twig_htmlspecialchars_decode</a> module, resulting in quite a long and clumsy filter chain ':[] <code> |striptags|trim|twig_htmlspecialchars_decode
- Rename it to
- 🇳🇱Netherlands Martijn de Wit 🇳🇱 The Netherlands
@camslice did you try the https://www.drupal.org/project/twig_field_value → module?
- 🇬🇧United Kingdom scott_euser
You can also use https://www.drupal.org/project/twig_remove_html_comments → which removes the html comments without removing the actual markup inside the nested template. I have suggested an update to the module homepage as it is outdated referencing this issue 📌 Module homepage description is in need of an update with incorrect information Active .
- Status changed to Closed: outdated
9 months ago 6:53am 16 February 2024 - 🇳🇿New Zealand quietone
@scott_euser asked that the status of this issue be change to 'closed won't fix'.
I have searched the issue and there is no commit here. I skimmed through the comments and do not see anything, like a documentation change, to suggest that this has been fixed. #36 closed this as outdated and the next comment changed the status to 'Fixed'. That was the mistake. If I know the issue where this was fixed there is a possibility that this could be closed as a duplicate and credit transferred. But, there is no reference to another issue so 'closed outdated' is the status to use.
Also, noting that there are comments suggesting the use of contrib projects, #57, #58, #59
I am restoring the status from #36
- 🇬🇧United Kingdom scott_euser
Thanks @quietone. In case people come across this issue because of debug comments added within formatted text, I separately raised 🐛 FilterAutoP should ignore twig.config debug html comments Needs review with a merge request proposing a solution.