On Fri, Nov 05, 2010 at 12:29:00PM +0200, sawyer x wrote:
Following a slip-up of BooK on our IRC channel, I've created Dancer::Template::Markdown.
Basically this allows you to write Markdown files and have them rendered by Dancer's template engine automatically.
Actually, my idea was to take some content in markdown or other format, and first render it using that format, and then process the result as a template. As I try to come up with an example, I realize there are two different use cases. Case 1: * produce HTML from a source format, with a few variables to replace using the template * so, source is rendered (in HTML) and the result is processed through the template engine Case 2: * generate content in the source format using the template engine, and then rendered it using the format * so the source is first processed using the template engine, and the result is then rendered (in HTML) using the format My use case was case 1, e.g. to be able to produce a documentation site from a collection of pod or markdown files. To be able to do that, I modified template to accept other paramaters than a file name. This allows the template source to be generated on the fly. Imagine a Dancer::Plugin::Formatter, providing a format keyword that returns the result of formatting some content with the given format. (using subclasses for Markdown, Pod, etc). # use case 1 template format( $source => 'markdown' ), $tokens, $options; # use case 2 format template( $view, $token, $options ) => markdown Actually this is overlooking the layout (which is now handled by the template). I'm not sure how to handle this. -- Philippe Bruhat (BooK) We vote to pick our leaders- / And we place them in a tower- Why is it that we cannot wait- / To vote them out of power? (Intro poem to Groo The Wanderer #109 (Epic))