]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/replace_HTML::Template_with_Template_Toolkit.mdwn
po plugin cleanup .pot files
[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 > Note that is no longer true, and I didn't have to do such an intrusive
9 > change to fix it either. --[[Joey]]
10
11 Maybe it's just me, I also find HTML::Template cumbersome to use, due in part
12 to its use of capital letters.
13
14 > Its entirely optional use of capital letters? --[[Joey]]
15
16 Finally, the software seems unmaintained: the mailing list and searchable
17 archives linked from
18 <http://html-template.sourceforge.net/html_template.html#frequently%20asked%20questions>
19 are broken and the author has not replied to my query in months.
20
21 I would love to see ikiwiki use the [Template
22 Toolkit](http://template-toolkit.org/) as templating engine.
23
24 One major reason for TT is its use of slots, a concept I first encountered
25 with Zope Page Templates and never wanted to miss it again. Let me quickly
26 illustrate, using the HTML::Template syntax for simplicity. Traditionally,
27 templating is done with includes:
28
29     Page A                              Page B
30     <TMPL_INCLUDE header>               <TMPL_INCLUDE header>
31     this is page A                      this is page B
32     <TMPL_INCLUDE footer>               <TMPL_INCLUDE footer>
33
34 This involves four pages, and if you mistype "footer" on page B,
35 it'll be broken in potentially subtle ways.
36
37 Now look at the approach with slots:
38
39     MainTemplate
40     This is the header
41     <TMPL_SLOT content>
42     This is the footer
43
44     Page A                              Page B
45     <TMPL_USE MainTemplate>             <TMPL_USE MainTemplate>
46       <TMPL_FILL content>                 <TMPL_FILL content>  
47         This is page A                       This is page B  
48       </TMPL_FILL>                        </TMPL_FILL>     
49     </TMPL_USE>                         </TMPL_USE>
50
51 As soon as you think about more structure pages with various slots
52 to fill, I am sure you can see the appeal of that approach. If not,
53 here is some more documentation: <http://wiki.zope.org/ZPT/METALSpecification11>
54
55 I would be glad to volunteer time to make this switch happen, such as rewrite
56 the templates. I'd prefer not having to touch Perl though...
57
58
59 -----
60
61 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/)
62
63 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]]
64
65 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
66
67
68 I agree that being able to replace the template toolkit would be a great piece of modularity, and one I would use. If I could use the slot-based filling and the conditional logic from Template::Toolkit, we could build much more flexible inline and archivepage templates that would look different depending on where in the wiki we use them. Some of this can currently be accomplished with separate templates for each use case and a manual call to the right template in the !inline directive, but this is limited, cumbersome, and makes it difficult to reuse bits of formatting by trapping all of that information in multiple template files. -Ian
69
70 > I don't wish HTML::Template to be *replaced* by Template::Toolkit - as
71 > others have said above, it's overkill for my needs.  However, I also
72 > agree that HTML::Template has its own problems too.  The idea of making
73 > the template system modular, with a choice of which backend to use - I
74 > really like that idea. It would enable me to use some other template
75 > system I like better, such as Text::Template or Text::NeatTemplate. But I
76 > think it would be a lot of work to implement, though perhaps no more work
77 > than making the revision-control backend modular, I guess.  One would
78 > need to write an IkiWiki template interface that didn't care what the
79 > backend was, and yet is somehow still flexible enough to take advantage
80 > of special features of different backends.  There are an *awful lot* of
81 > things that use templates - not just the `pagetemplate` and `template`
82 > plugins, but a number of others which have specialized templates of their
83 > own. -- [[KathrynAndersen]]a
84
85 >> A modular template system in ikiwiki is unlikely, as template objects
86 >> are part of the API,  notably the `pagetemplate` hook. Unless the other
87 >> system has a compatible template object. --[[Joey]]