Dancer::Template::Markdown
Hi all, 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. My question to all of you is: should I upload this to CPAN? Why yes: - It allows people to write their website in Markdown. - I could write an article around it for the Advent Calendar. - It could add to the Dancer myth of "if you even suggest an idea for an engine (session, template, serializer), it will probably already be on CPAN when you wake up the next morning" Why not: - Simply because Markdown is only a text syntax. It's not a template engine. You cannot put variables, loops, conditions and other template stuff in it. It will only be useful if you have static content written in Markdown. It's not really a "::Template". Where else would you otherwise put it? Then again, being able to offload the entire rendering to Dancer sure is a plus. Your views? Sawyer.
On Fri, Nov 5, 2010 at 5:29 AM, sawyer x <xsawyerx@gmail.com> wrote:
Hi all,
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.
My question to all of you is: should I upload this to CPAN?
Why yes: - It allows people to write their website in Markdown. - I could write an article around it for the Advent Calendar. - It could add to the Dancer myth of "if you even suggest an idea for an engine (session, template, serializer), it will probably already be on CPAN when you wake up the next morning"
Why not: - Simply because Markdown is only a text syntax. It's not a template engine. You cannot put variables, loops, conditions and other template stuff in it. It will only be useful if you have static content written in Markdown. It's not really a "::Template". Where else would you otherwise put it? Then again, being able to offload the entire rendering to Dancer sure is a plus.
Your views?
The plugin is a great idea.... I use a rather customized version of Markdown myself. What is misleading is to put it in the "Template" namespace. A template implies substitution of tokens of some kind with real data. Markdown is really a rendering engine. Perhaps a Dancer::Render::Markdown, so we can eventually have stuff like Dancer::Render::XML, Dancer::Render::PDF, Dancer::Render::whatever
Sawyer.
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
-- Puneet Kishor http://www.punkish.org Carbon Model http://carbonmodel.org Charter Member, Open Source Geospatial Foundation http://www.osgeo.org Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor Nelson Institute, UW-Madison http://www.nelson.wisc.edu ----------------------------------------------------------------------- Assertions are politics; backing up assertions with evidence is science =======================================================================
On Fri, Nov 5, 2010 at 4:50 PM, P Kishor <punk.kish@gmail.com> wrote:
The plugin is a great idea....
Thank you.
What is misleading is to put it in the "Template" namespace. A template implies substitution of tokens of some kind with real data.
Agreed. Franck suggested to name it Dancer::Plugin::Markdown.
Markdown is really a rendering engine. Perhaps a Dancer::Render::Markdown, so we can eventually have stuff like Dancer::Render::XML, Dancer::Render::PDF, Dancer::Render::whatever
Render sounds like Template to me just the same. I think I'll go with Plugin. Thanks for your input. S.
Le 05/11/2010 17:25, sawyer x a écrit :
Thank you.
What is misleading is to put it in the "Template" namespace. A template implies substitution of tokens of some kind with real data.
Agreed. Franck suggested to name it Dancer::Plugin::Markdown.
I also agree, using the "::Plugin" namespace seems appropriate. Great idea by the way, and if that brings one more article for the advent calendar, that's awesome. -- Alexis Sukrieh
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))
On Sat, Nov 06, 2010 at 10:06:02AM +0100, Philippe Bruhat (BooK) wrote:
Actually this is overlooking the layout (which is now handled by the template). I'm not sure how to handle this.
template() is handling the layout as a special case (layout option), and render_with_layout() calls template() in a way that forces the special case. This is probably a problem. As it prevents us from doing things like layout(template(format)) and layout(format(template)) easily. -- Philippe Bruhat (BooK) You can always buy another house but you cannot put a price on a home. (Moral from Groo The Wanderer #63 (Epic))
On Sat, Nov 06, 2010 at 10:49:05AM +0100, Philippe Bruhat (BooK) wrote:
On Sat, Nov 06, 2010 at 10:06:02AM +0100, Philippe Bruhat (BooK) wrote:
Actually this is overlooking the layout (which is now handled by the template). I'm not sure how to handle this.
template() is handling the layout as a special case (layout option), and render_with_layout() calls template() in a way that forces the special case.
This is probably a problem. As it prevents us from doing things like layout(template(format)) and layout(format(template)) easily.
It all comes down to the fact that generating the final page content requires two passes through the template engine: one to process the .tt file, and one for the layout. I think those two passes should be made more distinct. -- Philippe Bruhat (BooK) To flaunt your strength is to make it your weakness. (Moral from Groo The Wanderer #25 (Epic))
participants (4)
-
Alexis Sukrieh -
P Kishor -
Philippe Bruhat (BooK) -
sawyer x