Re: HTML::Template vs. Template::Toolkit vs. ??
by CountZero (Bishop) on Jan 06, 2009 at 22:35 UTC
|
Strictly Template::Toolkit here because it allows you to put logic inside or outside of templates as you like it. I use DBIx::Class a lot and I can just pass a recordset-object to the template and have the template loop over it and do all kind of things to it, such as sub-totalling, adding color depending on some field-values, ....I mainly use it on non-HTML templates: the perl-script gets the data out of whatever storage it is in, hands it to the template which writes a nice LaTeX-file which then gets rendered by the TeX engine into a über-nice PDF report.
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
| [reply] |
Re: HTML::Template vs. Template::Toolkit vs. ??
by jeffa (Bishop) on Jan 06, 2009 at 22:12 UTC
|
I use HTML::Mason these days, but only because i have used it now at 3 places of employment and have had the opportunity to work with some extremely bright developers at 2 of those places. I think reality has shown that the concept of passing off templates to HTML designers just isn't very practical. I have found myself having to massage their HTML into the web site regardless of how well the data was separated from the presentation. I am not saying it's a bad idea -- it's just an idea whose time already seemed to come and go.
| [reply] |
|
| [reply] |
|
We tend to get a PDF that represents that web page. It's usually up to us to turn that into HTML. Since this HTML is then sliced up and component-ized, it becomes very cumbersome for an HTML designer to pull the pieces together in their environment. So, these days I only have separation concerns that address simple organization -- not work flow.
Most environments just aren't as simple and self-contained as what CountZero describes. I wish they were.
| [reply] |
Re: HTML::Template vs. Template::Toolkit vs. ??
by MidLifeXis (Monsignor) on Jan 06, 2009 at 22:37 UTC
|
Display logic is also not the same as business logic. The part of using a template system that has bothered me the most, and caused me to switch to T::T, was that I had to still massage the data so that the display layer could deal with it in an efficient manner.
Since I have switched to T::T, I now leave the data in a structure that represents it well, and let the display logic handle the translation into what it needs. Now the data generation is (fairly) stable, and presentation is handled in the template.
That being said, I agree with jeffa's comment above that the templates are still code, just with limited access to the data provided.
| [reply] |
Re: HTML::Template vs. Template::Toolkit vs. ??
by zby (Vicar) on Jan 07, 2009 at 08:20 UTC
|
I used to use TT - but now at work I am back to HTML::Template. For me it is a step back - mostly for one thing: with TT I can pass an object or other structure to it and I know that I'll be able to display it, with HTML::Template I need to convert the data to the format acceptable by the templating engine. In other words with TT it is like "fire and forget" - just remember to pass all info needed, with HTML::Template you need an additional step. | [reply] |
Re: HTML::Template vs. Template::Toolkit vs. ??
by LanX (Saint) on Jan 07, 2009 at 00:44 UTC
|
| [reply] |
Re: HTML::Template vs. Template::Toolkit vs. ??
by monarch (Priest) on Jan 07, 2009 at 00:04 UTC
|
Mason and Template Toolkit basically generate Perl code. HTML::Template, on the other hand, is a pure separation of template from code.
Should you be concerned if the module hasn't been updated in some time? Only if you find yourself worrying when the IPv4 protocol is still in use without any significant changes for some time. Only if you find the cron daemon a bit outdated for your liking.. My point is that if something works and does what it says on the box then stability is generally a good thing.
Updated: grammatical corrections.
| [reply] |
|
HTML::Template, on the other hand, is a pure separation of template from code.
It is rather pure (moreso than tt/mason), but Petal is purer and HTML::Seamstress is even more pure.
| [reply] |
Re: HTML::Template vs. Template::Toolkit vs. ??
by SouthFulcrum (Sexton) on Jan 07, 2009 at 01:14 UTC
|
I have no business comparing the various template modules as I've only always used Template Toolkit. However, that fact stands to say I've never thought "This is annoying, maybe I should look at the other templateing engines." I realize that might not sound helpful, but TT is wonderful and I don't see it being "abandoned" anytime soon (though I wouldn't assume HTML::Template is actually "abandoned").
If you like and are comfortable with HTML::Template and hear back that it is "just that stable", then whatever. However, Template Toolkit has improved my quality of life. It is as powerful as it is usable. TT (via plugins) is not just for HTML.
| [reply] |
Re: HTML::Template vs. Template::Toolkit vs. ??
by moritz (Cardinal) on Jan 07, 2009 at 19:44 UTC
|
I started out with using HTML::Template, it was the first template system that I knew, and I liked it.
I then read a Catalyst tutorial, and that used TT. I really liked it, and started using TT.
My first doubts about TT came when realized that it missed a killer feature that HTML::Template had: the default_escape option. It really makes all your worries about cross-site scripting go away.
When I tried to make my web apps "Unicode Safe" I moved them from HTML::Template to HTML::Template::Compiled, which has the open_mode option to get rid of my UTF-8 worries.
I started to write more things with Catalyst, DBIx::Class and TT, and came to the conclusion that this model, while much more powerful than HTML::Template + $otherStuff, tempted me to do bad things, like issuing DB queries from within the template (if you don't know what's bad about this, just think of how you'd handle error cases).
So these days I mostly use HTML::Template::Compiled again. | [reply] [d/l] [select] |
|
| [reply] |
|
what I don't quite like about that is, that if you need unescaped data, you have to decode it, so that produces extra work (encoding and directly after that decoding again), while in HTML::Template(::Compiled) no escaping at all happens if you use ESCAPE=0.
| [reply] |
|
Thank you, that looks nice (although I don't see an example of how the decoding works). The last time I asked, nobody had a convenient answer, so I guess things are improving still (which is a good sign).
| [reply] |
|
I'm currently using HTML::Template and having some Unicode issues. For example a parameter of '\x{a3}' gets converted to '\x{c2}\x{a3}' in the return value of 'output' - that is the individual UTF-8 bytes appear to get interpreted as Unicode code points.
For reference this is a pound sign and the Unicode code point is '00A3' and the UTF-8 hex is 'C2','A3'.
| [reply] |