mmikkel / Retcon-Craft

A collection of powerful Twig filters for modifying HTML
MIT License
79 stars 9 forks source link

retconChange fails with empty p tags #49

Closed dillonbailey closed 1 year ago

dillonbailey commented 1 year ago

The workaround was to add a replace filter to strip the tags, but assuming not everyone will find this ideal:

{{ block.heading | replace('/<[^\\/>][^>]*><\\/[^>]+>/', '') | retconChange('p', 'h2') }}

Before implementing the workaround, the following error would be produced:

Screenshot 2023-02-17 at 1 04 09 pm

Based on the redactor field containing the following values in twig (without any filters):

<p dir="ltr"></p>
<p>An interesting heading</p>
<p></p>                
Screenshot 2023-02-17 at 1 07 04 pm
mmikkel commented 1 year ago

Thanks for reporting that! Just published Retcon v. 2.6.1 with a fix.

dillonbailey commented 1 year ago

Amazing! Thanks @mmikkel