This one’s just for the nerds
but I wanted to show it off and see if anyone else came up with any solutions.
On my blog I end up writing about hubl a lot. So I end up having to use {% raw %} tags a lot.
To speed this up I added some filters to my template that automatically adds {% raw %} tags to <pre> tags.
{% set modified_content = content.post_body|replace('<pre>', '<pre>{% raw %}')|replace('</pre>', '{% endraw %}</pre>')|replace('<raw>', '{% raw %}')|replace('<endraw>', '{% endraw %}')|replace('< raw >','<raw>')|replace('< endraw >','<endraw>') %}
{% if request.postDict.inpageEditorUI %}
{{ content.post_body }}
{% else %}
{{ modified_content }}
{% endif %}
You’ll note that there’s a number of other filters there, because it’s weirdly hard to write about {% raw %} tags
it’s almost a recursive loop of filters, but not quite.
You’ll also notice that we’re not using the filtered content on the edit page. For whatever reason post_body content hates getting messed with on the edit page.
It’s still not perfect, sometimes the richtext editor with thow a span in there than messes everything up (It throws a <span> in the works! Ha!) But I think it’s going to be really hand for me when writing about hubl going forward.
Did a bit of a write up on it here.
Barry Grennan
