web commit by http://madduck.myopenid.com/
[ikiwiki] / doc / todo / replace_HTML::Template_with_Template_Toolkit.mdwn
1 HTML::Template is an okay templating kit, but it lacks a lot of powerful
2 features and thus makes it rather hard to give an ikiwiki site a consistent
3 look. If you browse the templates provided in the tarball, you'll notice that
4 more than one of them contain the `<html>` tag, which is unnecessary.
5
6 Maybe it's just me, I also find HTML::Template cumbersome to use, due in part
7 to its use of capital letters.
8
9 Finally, the software seems unmaintained: the mailing list and searchable
10 archives linked from
11 <http://html-template.sourceforge.net/html_template.html#frequently%20asked%20questions>
12 are broken and the author has not replied to my query in months.
13
14 I would love to see ikiwiki use the [Template
15 Toolkit](http://template-toolkit.org/) as templating engine.
16
17 One major reason for TT is its use of slots, a concept I first encountered
18 with Zope Page Templates and never wanted to miss it again. Let me quickly
19 illustrate, using the HTML::Template syntax for simplicity. Traditionally,
20 templating is done with includes:
21
22     Page A                              Page B
23     <TMPL_INCLUDE header>               <TMPL_INCLUDE header>
24     this is page A                      this is page B
25     <TMPL_INCLUDE footer>               <TMPL_INCLUDE footer>
26
27 This involves four pages, and if you mistype "footer" on page B,
28 it'll be broken in potentially subtle ways.
29
30 Now look at the approach with slots:
31
32     MainTemplate
33     This is the header
34     <TMPL_SLOT content>
35     This is the footer
36
37     Page A                              Page B
38     <TMPL_USE MainTemplate>             <TMPL_USE MainTemplate>
39       <TMPL_FILL content>                 <TMPL_FILL content>  
40         This is page A                       This is page B  
41       </TMPL_FILL>                        </TMPL_FILL>     
42     </TMPL_USE>                         </TMPL_USE>
43
44 As soon as you think about more structure pages with various slots
45 to fill, I am sure you can see the appeal of that approach. If not,
46 here is some more documentation: <http://wiki.zope.org/ZPT/METALSpecification11>
47
48 I would be glad to volunteer time to make this switch happen, such as rewrite
49 the templates. I'd prefer not having to touch Perl though...