Le 17/10/2012 19:58, Fred Loney a écrit :
Is there a Markdown Jinja extension, along the lines of the Django
extension <http://freewisdom.org/projects/python-markdown/Django>? I
want to serve markdown files formatted as HTML in the Klaus
<https://github.com/jonashaag/klaus#readme> git viewer, which uses Jinja.
Hi,
I don’t think there is a need for an extension since any function can be
registered as a filter:
Python:
import jinja2
import markdown
def safe_markdown(text):
return jinja2.Markup(markdown.markdown(text, ...))
env = jinja2.Environment(...)
env.filters['markdown'] = safe_markdown
Templates:
{{ something.markdown_text|markdown }}
{% filter markdown %}
You can have *inline* Markdown too!
{% endfilter %}
Cheers,
--
Simon Sapin
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pocoo-libs?hl=en.