Liquid, JavaScript, themes, sales channels
I am trying to strip empty `<P>` tags from a block of HTML within a Shopify theme. For some reason the `remove` filter is not detecting whatever the space character is inside the tag. I've even tried copy/pasting from source code into my command and it's not working.
{{ article.content | remove: '<p> </p>' | remove: '<p> </p>' }}
With this, it still remains:
Did you have luck with replace?
In addition, are these tags for sure coming from the article or is there a chance they could be being dynamically injected?
Thanks for the reply. Yes I have tried `replace` as well. I even tried replacing all space characters with something else and the `<p> </p>` remained in the raw HTML output. It seems to be some kind of other space character but everything I try can't strip it out.
For the sake of testing, are you able to stripe out only the <p>?
Yes I can. But I can not strip out whatever Shopify thinks `<p> </p>` is.
Hi @Louis_Walch,
You can try with code: {{ article.content | remove: '<p></p>'}}
Or the best way, go to the articles, edit each HTML of the content, it's the best way: https://i.imgur.com/ZN2ODqB.png
Hope it helps!
I ended up cleaning it up with Javascript. Maybe not the best solution but liquid just seemed to limited and was not cooperating.
If anyone needs it:
`.replace( / /g,'' ).replace(/<p><\/p>/gi, '').replace(/<div><\/div>/gi, '')`
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024