APIs & Integrations

cabplanalp
Participant

HubL how to remove all html formatting pulling in post content for teaser

SOLVE

I have a Blog template using this HubL code:

{{ topic_post.post_list_content|safe }}

This pulls in the post content (not sure what safe is really doing) but it truncates it after first paragraph. The issue is that all links are pulling in, so I want to remove all the formatting from the content teasers I am pulling in.

What is the HubL variable I can add to remove all HTML formatting so <a href> code does not pull in?

0 Upvotes
1 Accepted solution
cabplanalp
Solution
Participant

HubL how to remove all html formatting pulling in post content for teaser

SOLVE

I found a solution right after I submitted the question, here is a " | striptags" HubL filter:

striptags(value)

Strip SGML/XML tags and replace adjacent whitespace by one space.

Example: Strip any HTML markup that may have been added in the comments form

on this article:

https://designers.hubspot.com/docs/markup/supported-filters

After applying this filter, it stripped the HTML tags:

{{ topic_post.post_list_content|safe|striptags }}

View solution in original post

1 Reply 1
cabplanalp
Solution
Participant

HubL how to remove all html formatting pulling in post content for teaser

SOLVE

I found a solution right after I submitted the question, here is a " | striptags" HubL filter:

striptags(value)

Strip SGML/XML tags and replace adjacent whitespace by one space.

Example: Strip any HTML markup that may have been added in the comments form

on this article:

https://designers.hubspot.com/docs/markup/supported-filters

After applying this filter, it stripped the HTML tags:

{{ topic_post.post_list_content|safe|striptags }}