I have a text field in my model that contains markdown text. I need to convert the text to html and show it in my .pt template. what is the best way to do it?
I realise that I can add a method to my model that converts the field and returns HTML, and then call the method from my template, but can I do it without this extra method, by using only the markdown field in my template similarly to Django’s?
{{ mytext|markdown:"safe" }}
Plone, which uses TAL for it’s templating engine and can use StructuredText, reStructuredText, and other rich text formats, does all the rendering to HTML outside TAL. So you might be barking up the wrong tree in the approach you’re going for.
That said, TAL has a somewhat extensible “expression” system which is why you can have
pathexpressions (the default) orpythonexpressions. In the zope world, which includes plone, there’s a page composition system called content providers, so someone implemented aprovidertal expression. So maybe you can look at that:tales.pyconfigure.zcmlThe
structurekeyword is still your easiest bet.But
structureis a special case keyword and not an extensible part of page templates.