A client imported their blog in such a way that all the html, scripts, etc. are in the text editor for blog content.
It looks fine on the imported blogs, but they’d need to know html to replicate it on any new blogs.
The new blog template will require custom modules to replicate layout, so rather than going through all the existing posts and manually copying over the data to the modules, I’d like to set placeholders that pull from the content.post_body initially.
So far I’ve done this:
{% module_block module “module_0000000” path=“/theme/_modules/my_module” %} {% module_attribute “text” %} <!-- START --> {{ content.post_body }} <!-- END --> {% end_module_attribute %} {% end_module_block %}
Which pulled in all the imported html as the content of the text attribute of “my_module”.
But I want to try to use regex_replace to remove content before and after a h6 for example to pull a custom mane that has been enter in the html. So:
< head ></ head > < body > < main > Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eu rutrum enim. Vivamus id ex pharetra, posuere massa nec, hendrerit lacus. Pellentesque pellentesque, dui sed fermentum iaculis, ligula libero bibendum mi, a tincidunt mauris tellus sed nibh. Phasellus ac magna ac urna feugiat tincidunt ac nec arcu. Nullam lobortis ipsum ut dolor ornare, quis eleifend nisi sollicitudin. Cras egestas, ante vitae finibus rutrum, libero tellus finibus metus, nec rhoncus ipsum lacus at metus. Donec non ipsum vitae ante tempus semper. Sed sed ultrices, eu cursus tortor. </ main > < aside > <h6>I'm a heading</h6> </ aside > </ body >
I want the opposite of:
{{ content.post_body|regex_replace('<h6>(.*?)</h6>','') }}
Replace everything but h6 content