Strip HTML characters using Liquid in PowerApps/ Dynamics 365 Portals

I have been working lately a lot on PowerApps portals and one of the requirement that we got from customer is to render some HTML text as text in Portals. The customer had a field in Dynamics 365 which was storing rich text.
We would retrieve the field value using fetchxml in liquid and the requirement was to strip the HTML characters and show the text in plain text. We did that initially in JS, only to realize later that there is a specific filter available in liquid – “strip_html”.
And guess what it worked like a charm.
Input:
{{ “<span>This liquid filter <b>can work wonders</b> with stripping HTML<br />” | strip_html}}
Output:
This liquid filter can work wonders with stripping HTML
As I am working more and more on liquid, I am simply falling in love with it. Simple yet quite powerful language. And as I keep exploring, I will post some interesting stuffs over the next few weeks.
Hopes this helps!
Debajit Dutta
(Dynamics MVP)
For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com
Our product offerings:
CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)
Notes Manager (https://debajmecrm.com/add-metadata-to-your-notes-and-attachments-in-dynamics-notes-metadata-manager-from-xrmforyou-com/)
Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)
Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)