CMS Development

mpq
Participant

Split html document in array/list

Is there a way to split a html in a list of elements.

For example my content.post_body is something like 

<span>

<p></p>

<p></p>

<p></p>

.....

<h3></h3>

...

<a></a>

..

<p></p>
</span>

So I want all content of the span to beacome a list of p, a, h3 ...

Next i will manipulate all elements and print them.

 

This becouse on my blog template I need to manipulate and edit a lot of things, so to use pipeline on functions.

 

But now I can't becouse is just one element, so something like content.post_body | replace('ok','okey') I can do, but edit an attribute just in one part and not in all content is not possible. So I need to interate on the content and edit what I want and then print it

 

0 Upvotes
1 Reply 1
mherzog
HubSpot Product Team
HubSpot Product Team

Split html document in array/list

Hey there! There's not currently a great way to modify this in HubSpot blogs- we're looking into ways to make this sort of iteration possible, but for now, you'd need to separate the post_body from the general content of your post. This requires a fully coded blog template. You could use the post_body for RSS and listing preview content only, and hide it from the body of the post, and then add your own standalone HTML elements or modules to modify the actual post content. This would allow you to edit specific pieces of the post content.

0 Upvotes