Sherwood Botsford wrote:
> What's the clean way to do this?

Rather than implement your own markup language, I'd suggest looking at
Markdown first.

   http://daringfireball.net/projects/markdown/

You'll need to install Text::Markdown and Template::Plugin::Markdown from
CPAN.  If you don't fancy Markdown you can write your own filter and plug
it into TT in much the same way,

Then you can use the WRAPPER option to apply a standard wrapper template
something like this:

   [% INCLUDE header;
      content FILTER markdown;
      INCLUDE footer
   %]

Then your page content can be like this:

   This is a headling
   ==================

   A bit of text

   * The first item in the list
   * Just another list item
   * OMG! It's a list item!

   Some more text

   Even a subhead
   --------------

Note that this is still a regular template which gets processed (via TT)
before being piped through Markdown.  So you can have your regular TT markup
in the template as well.  You can even use TT to generate Markdown if you
want. e.g. to generate a Markdown bullet list:

   [% FOREACH item IN ['foo', 'bar', 'baz'] %]
   * [% item %]
   [% END %]

If you want to mix Markdown pages with regular HTML templates, you can do
something like this in the wrapper template:

   [% INCLUDE header;

      IF template.markdown;
        content FILTER markdown;
      ELSE;
        content;
      END;

      INCLUDE footer
   %]

Then to trigger the "filter this page through markdown" behaviour, you just
need to add a META tag to the top of the template like this:

   [% META markdown=1 %]
   # rest of template...

HTH
A


_______________________________________________
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to