]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/replace_HTML::Template_with_Template_Toolkit.mdwn
close
[ikiwiki.git] / doc / todo / replace_HTML::Template_with_Template_Toolkit.mdwn
1 [[!tag wishlist]]
2
3 HTML::Template is an okay templating kit, but it lacks a lot of powerful
4 features and thus makes it rather hard to give an ikiwiki site a consistent
5 look. If you browse the templates provided in the tarball, you'll notice that
6 more than one of them contain the `<html>` tag, which is unnecessary.
7
8 Maybe it's just me, I also find HTML::Template cumbersome to use, due in part
9 to its use of capital letters.
10
11 Finally, the software seems unmaintained: the mailing list and searchable
12 archives linked from
13 <http://html-template.sourceforge.net/html_template.html#frequently%20asked%20questions>
14 are broken and the author has not replied to my query in months.
15
16 I would love to see ikiwiki use the [Template
17 Toolkit](http://template-toolkit.org/) as templating engine.
18
19 One major reason for TT is its use of slots, a concept I first encountered
20 with Zope Page Templates and never wanted to miss it again. Let me quickly
21 illustrate, using the HTML::Template syntax for simplicity. Traditionally,
22 templating is done with includes:
23
24     Page A                              Page B
25     <TMPL_INCLUDE header>               <TMPL_INCLUDE header>
26     this is page A                      this is page B
27     <TMPL_INCLUDE footer>               <TMPL_INCLUDE footer>
28
29 This involves four pages, and if you mistype "footer" on page B,
30 it'll be broken in potentially subtle ways.
31
32 Now look at the approach with slots:
33
34     MainTemplate
35     This is the header
36     <TMPL_SLOT content>
37     This is the footer
38
39     Page A                              Page B
40     <TMPL_USE MainTemplate>             <TMPL_USE MainTemplate>
41       <TMPL_FILL content>                 <TMPL_FILL content>  
42         This is page A                       This is page B  
43       </TMPL_FILL>                        </TMPL_FILL>     
44     </TMPL_USE>                         </TMPL_USE>
45
46 As soon as you think about more structure pages with various slots
47 to fill, I am sure you can see the appeal of that approach. If not,
48 here is some more documentation: <http://wiki.zope.org/ZPT/METALSpecification11>
49
50 I would be glad to volunteer time to make this switch happen, such as rewrite
51 the templates. I'd prefer not having to touch Perl though...
52
53
54 -----
55
56 Yes, Template::Toolkit is very powerful. But I think it's somehow overkill for a wiki. HTML::Template can keep things simple, though.  --[weakish](http://weakish.int.eu.org/blog/)
57
58 I'd have to agree that Template::Toolkit is overkill and personally I'm not a fan, but it is very popular (there is even a book) and the new version (3) is alleged to be much more nimble than current version.  --[[ajt]]
59
60 HTML::Template's HTML-like markup prevents me from editing templates in KompoZer or other WYSIWYG HTML editors.  The editor tries to render the template markup rather than display it verbatim, and large parts of the template become invisible.  A markup syntax that doesn't confuse editors (such as Template::Toolkit's "[% FOO %]") may promote template customization.  The ability to replace the template engine would be within the spirit of ikiwiki's extensibility. --Rocco