On my current side project, I wanted to add support for writing text entries in markdown and have the templates output the text in html. Thanks to markdown-clj by Dmitri Sotnikov, this was very simple.
In a namespace for my project's filters, I required markdown-clj, then passed Clabango's body argument to md-to-html-string:
(ns logbook.filters
(:require [clabango.filters :as filter]
[markdown.core :as md]))
(filter/deftemplatefilter "markdown" [node body args]
(when body (md/md-to-html-string body)))
Note that the return value of the deftemplatefilter is a string, rather than the map that Clabango's current examples demonstrate. There is a difference between the source on Github and the binary on Clojars.
Now wherever I need to convert text from markdown to html in a Clabango template, I pass the text to the new markdown filter:
-
{% for entry in entries %}
- {{ entry.title|markdown }} {% endfor %}
Update: Dmitri has released Selmer.