Survey of Surveys on HTML Templating systems / Web Frameworks (Sorting out the Technology Soup)
UPDATE: I either missed Catalyst, or Catalyst wasn't out yet, when I first posted this. At this point in time, I am devoting most of my "web framework learning" energy to learning this framework. Run and check it out!
I need to choose an html templating system that plays well with Dreamweaver for the design aspects, and an open source db (mysql or postgres) for the back end.
Ideal would be a mock application (or open source real application) written with Mason or Embperl (my top choices) including a framework for managing the db, that's all ready to go, and I can just start tinkering with it to suit my purposes, rather than start something from scratch. But I wasn't able to find anything like that.
Anyway, after spending some time doing research mainly with perlmonks and google, I thought it would be helpful to others in my situation to present a survey of my findings. There is a LOT written about this, without a clear "winner" in the competing technology soup. (Though as stated above, I'm beginning to lean towards Mason/Embperl.)
UPDATE: There's a mason demo at Perl Apprenticeship Site. Unfortunately I don't think this is db enabled, but I could be wrong about that -- need to check into this more carefully. This is the "official" sample site described in the masonbook. More promisingly, there a number of mason powered apps at mastonhq.com. Bricolage uses postgres, I may be looking at that first.
A not very satisfying demo of embperl is at Talk on Apache, mod_perl, and embperl
Also, Metaperl (aka princepawn) was kind enough to provide me with a demo app of his Seamstress framework. There is no link to do this from his web page, but ask nicely and hopefully you will be in luck.
Metaperl also referred me to the "bivio" framework, which also has a demo "petshop" webshop, nicely tar.gzed. (See discussion below). However, in The Bivio Model and Algorithm for Authorization (slides available), Metaperl notes that even after intensive study bivio strained his powers of understanding... which I find kind of scary. So, I may choose to study bivio as an example of a really cool framework, but do my real work in Mason (or possibly Seamstress).
Overview
Of hisorical interest may be jonas liljegren's rant (undated, my guess is 1999 or before)
- Back in the day, he was "Frustrated about all these template models!"
- Of major modern templating systems, mentions only HTML::Template.
- The more things change, the more they stay the same.
A more current major article on the topic is perrin's Choosing a templating system also at perl.com here. (Last major change Jun 5 2002, originally written Sep 21 2001. I gave both urls since the article appears to be updated occasionally, so maybe one is more current than the other.)
- A long article that attempts to compare all major modern perl templating systems.
- At the end it's findings are summarized as:
|
Application Framework
|
Pipeline or Callback
|
Parsing Method
|
Language
|
HTML::Mason
|
Framework
|
Callback
|
Compiled
|
Perl
|
Template Toolkit
|
Just Templates
|
Pipeline
|
Compiled
|
Mini-Language
|
Apache::ASP
|
Framework
|
Callback
|
Compiled
|
Perl and XSL
|
HTML::Embperl
|
Framework
|
Callback
|
Compiled
|
Perl
|
SSI
|
Just Templates
|
Callback
|
Repeated Parse
|
Mini-Language
|
AxKit
|
Framework
|
Pipeline
|
Compiled or Cached Parse Tree
|
Perl and XSL and Mini-Language(s)
|
HTML::Template
|
Just Templates
|
Pipeline
|
Cached Parse Tree
|
Mini-Language
|
Text::Template
|
Just Templates
|
Pipeline
|
Compiled
|
Perl
|
This led me to conclude I probably want to use either Mason or Embperl, as these are the two top contenders for frameworks.
Pertinent to perl newbies for getting started on web apps is How to calculate development time?. Newbie (at the time) Siddharta asks, and gets, advice for building a web application from scratch. This is mainly about estimating project time, but there is also a lot of advice on which framework to use. Good thread.
And, some Perlmonks threads that discuss the pros and cons of various templating systems without a clear consensus preference for a particular one.
What is the best tool to embed perl in HTML? (Q&A, August 2, 2000) / Best templating system? (Jun 30 2000)
Mason, Embperl, and Template are recommended by various monks.
It's stated that Embperl plays well with Dreamweaver
Refining the CGI process through structure and templates (Apr 16, 2001, Boo Radley)
- Started by Boo Radley, attempting to roll his own Web/CGI framework
- Recommended by princepawn on his home node.
- Corion plugs HTML::FormValidator and others agree
OO CGI Engine (Jan 2 2002)
- Discussion of OpenInteract, CGI::Application, and HTML::Template, with positive things to say about all these.
- dnmiller2k mentions that CGI::Application uses HTML::Template, but Swiftone counters that this is just for installation, and you can use it with Template-Toolkit if you want.
Update: No demo for "open interact", at least none that I could find. But supposedly it's coming soon.
Another perrin article that's worth a read is Building a Large-scale E-commerce Site with Apache and mod_perl, which recounts his adventures at now-defunct etoys.
- Princepawn and Merlyn have posted much information and musing on this topic. Of course there are others, but for some reason I kept coming across these two in my own researches.
- Princepawn Stuff:
- Princepawn has come up with his own framework, Seamstress, though I'm not sure how serious he is about it. His node has a list of various perl html templating frameworks, including a lot of obscure ones.
- Web Application Frameworks and their Templating Engines with a Comparative Study of Template and HTML::Template (princepawn, apr 26 2001)
- In rant on = qw(HTML::Mason Embperl Template etc) ; (Nov 09, 2001) princepawn argues that his Seamstress is better than the alternatives. Criticizes not only Mason, but also Embperl and Template. I think this puts princepawn in a similar camp as merlyn, along the lines that flexibility is more valuable than an extended heavily used/tested framework like mason which has overhead that never gets used, or that gets in the way. But maybe I'm oversimplifying
- And he pops up in various other discussions, such as Template Toolkit vs HTML::Mason (merlyn and princepawn)
- And mini-languages for MVC view/controller manipulation, which is a little flamy on Seamstress versus Mason, but not too bad.
- Merlyn Stuff:
- mason and embperl Sep 02, 2000 / Text::Template morphs into Template Toolkit vs HTML::Mason (Oct 22 2000)
- Merlyn used mason for a while and likes it, but eventually switches over to template toolkit. I think for him, Template Toolkit is just the more flexible option. Merlyn is a perl wizard though... maybe for a beginner Mason would be more appropriate. ?
Dreamweaver and Perl
Jeffa wrote HTML::Template extensions for dreamweaver which enables you to "se HTML::Template tags in Dreamweaver just like they would any other object - by clicking on an icon which places the resulting HTML code in the document."
But it's no longer being maintained.
Two perlmonks threads about this.
- Dreamweaver/Perl integration tools (Dec 8 2001)
- User wants help integrating Dreamweaver Templates (a Dreamweaver feature not to be confused with perl templating) and perl (doesn't specify which perl web framework)
- Adviced that Jeffa put together a tool that helps you manage perl from within Dreamweaver, using Dreamweaver's "Dreamweaver Template" feature
- Tphyahoo (me) mentions MasonAndDreamweaver at the MasonHQ wiki. This seems to indicate that Mason and Dreamweaver play together okay.
- HTML::Template and Dreamweaver MX (Nov 21 2003)
- Newbie asks for help with Dreamweaver and HTML::Template (not specifying he wants help with Dreamweaver Templates)
- Newbie is advised to have a look at Jeffa's tool for integration with Dreamweaver Templates (I think this advice was confused).
- Jeffa states that he hasn't been maintaining this since 2001, and it's now out of date since there have been a lot of changes with Dreamweaver MX. "Dreamweaver is a "funky beast" says Jeffa.
- Tphyahoo (me) mentions that Dreamweaver Templates are a special Dreamweaver feature, which aren't used on every project, and suggests Mason, linking back to the 2001 article.
Also found CGI.pm - Dreamweaver or somesuch? (April 2001)
- Newbie asks for help integrating perl and dreamweaver
- Monks express general disdain for Dreamwever
Conclusion: Dreamwever Templates and perl, maybe not such a good idea. However, Dreamwever and Mason, maybe not such a bad idea. Also What is the best tool to embed perl in HTML? stated that Embperl and Dreamweaver is ok.
Descriptions/Tutorials on particular frameworks
HTML::Mason module review (Feb 1 2001)
- Overall positive review of this (at the time) new framework
Perl.com article Using CGI Application (June 5 2001)
I'm sure there's a lot more, so if I get comments I will try to update as appropriate.
Other stuff
Edit by tye: Remove P tags inside TABLE
Re: Survey of Surveys on HTML Templating systems
by dimar (Curate) on Feb 23, 2005 at 16:16 UTC
|
Excellent.
Templating systems are very similar to text editors / IDEs. Almost everyone has one, and everyone has reasons why their own personal favorite is "the best". This inclination also tends to bias people against trying other systems when they already know how to use one that suits their purposes and preferences. The result is myopic entrenchment.
Consequently, an unbiased observer is not very likely to find a legitimate side-by-side comparison without a lot of hard work and fortitude not to be swayed by people's (sometimes ill-informed) opinions.
Good job, *definitely* update this as appropriate. This kind of 'neutral' evaluation is a definite (++).
Now, if you could do a similar analysis for text editors and IDEs and have a report up by tomorrow morning, that'd be great mm'kay? ;-)
| [reply] |
Re: Survey of Surveys on HTML Templating systems
by fergal (Chaplain) on Feb 23, 2005 at 20:06 UTC
|
None of the surveys I've seen look at Petal which is based on Zope's TAL/ZPT. As far as I'm concerned there is no other way to do HTML/XML templates.
Example:
Welcome back <b tal:content="user/name">Sample Username</b>,
you last logged in <i tal:content="user/last_login">Sat 23rd Aug</i>
When you look at this in dreamweaver or a browser you'll see
Welcome back Sample Username, you last logged in Sat 23rd Aug
(view source on this page and you'll see that I have simply pasted in the code)
When you run this through the Petal engine you pass in a hash of data, say $h. Assuming
$h = {
user => {
name => "Fergal Daly"
last_login => "Feb 22nd"
}
}
The processed output will be
Welcome back Fergal Daly, you last logged in Feb 22nd
As you can see, the HTML beforehand is well formed, includes sample values for the dynamic parts and all you have to do with Dream weaver is apply styles to the sample data and all will be well. At template compile time, all the sample data is discarded and then at run time, the real data is inserted.
Of course TAL handles loops and conditionals etc. The thing that takes the most getting used to is that it's a little verbose. Unfortunately this is a necessary side effect of being truly compatible with XML/HTML.
| [reply] [d/l] [select] |
|
Welcome back <b tal:content="user/name">Sample Username</b>,
you last logged in <i tal:content="user/last_login">Sat 23rd Aug</i>
And when you look at this in dreamweaver or a browser you'll see
Welcome back Sample Username, you last logged in Sat 23rd Aug
And assuming
$h = {
user => {
name => "Fergal Daly"
last_login => "Feb 22nd"
}
}
The processed output will be
Welcome back Fergal Daly, you last logged in Feb 22nd
Now for the big difference
Of course TAL handles loops and conditionals etc.
Seamstress does not. Perl has loops and conditionals and sees no need
for their re-invention.
The thing that takes the most getting used to is that it's a little
verbose. Unfortunately this is a necessary side effect of being
truly compatible with XML/HTML.
I agree with you here, but I personally could have it no other way
either. Here is how seamstress would template the same thing:
require html::welcome_form;
my $tree = html::welcome_form->new;
my $user_name = $tree->look_down('tal:content' => 'user/name');
$user_name->replace_content($hash->{user}{name});
my $last_login = $tree->look_down('tal:content' => 'user/last_login);
$last_login->replace_content($hash->{user}{last_login});
or with a loop
for my $content (qw(name last_login)) {
$tree->look_down('tal:content' => $content)
->replace_content($hash->{user}{$content});
}
| [reply] [d/l] [select] |
|
<table>
<tr tal:repeat="thing user/things">
<td tal:content="thing/name">Widgets </td>:
<td tal:content="thing/count">10</td>
</tr>
</table>
this will produce one row for every element of $h->{user}->{things}.
That's as complex as you can get with loops. You just supply an array and Petal loops over it. This forces you to prepare all your data in advance and then just pump it into the template (although you can call methods as well as doing hash lookups so it's possible to lazily produce the data only as it's needed).
| [reply] [d/l] [select] |
|
|
|
|
I'm in the process of updating my article, and it will include Petal. The HTML_Tree module referred to in the current version is a dead project now.
| [reply] |
Re: Survey of Surveys on HTML Templating systems
by metaperl (Curate) on Feb 23, 2005 at 17:47 UTC
|
| [reply] |
|
I would say Petal offers the same sort of approach as Seamstress. It's pretty mature and seems to have an active community.
| [reply] |
|
I would say Petal offers the same sort of approach as Seamstress.
I thought Petal was the same thing as Seamstress but after joining the GMANE list and reading the docs it is very different.
- Petal provides a mini-language. Seamstress and XML::LibXML usage is nothing but object-oriented Perl.
- Petal is xml-based, which is fine if you have well-done XHTML. Seamstress is based around the flexible HTML::TreeBuilder which uses HTML::Parser and can use old skool HTML with no problem.
- did you see my post about creating alternating table rows with Petal? The way to do that in Seamstress or XML::LibXML is vastly different and in neither of our cases involves a mini-language.
| [reply] |
|
Hi, thanks for your feedback!
No, I haven't looked at the docs for Seamstress, just what I find clicking around in perlmonks. I was pretty overwhelmed by the amount of information out there and couldn't follow everything up. Maybe I'll have a closer look now.
One thing that might move me to try Seamstress is if there was a dummy application with a db back end that I could just take over and mold to my purposes. Is that what I'll get by clicking the view source link as you suggest? Going to check it out...
| [reply] |
|
Okay the view source thing is cool, but what I really want is the thing downloaded in a tarbell, including db dump, where I can play with it and see if I like it.
For instance, my first question is, where are the html templates? I guess they're in there somewhere, but how close to html do they look like? Close enough that I can load them in dreamweaver?
If you just tarballed the whole thing you might get more people playing with it, that's what MS does with ASP.net.
But from viewing the source I agree it's clean, it's nice, it looks promising.
| [reply] |
|
Re: Survey of Surveys on HTML Templating systems
by perrin (Chancellor) on Feb 23, 2005 at 19:06 UTC
|
This led me to conclude I probably want to use either Mason or Embperl, as these are the two top contenders for frameworks.
There are actually many frameworks based on the other templating modules, but I didn't review them because I was trying to limit the scope of that article. There's a partial list here. I also submitted a talk this year about MVC systems like Maypole, OpenInteract2, and Catalyst. | [reply] |
Dont forget bivio!
by metaperl (Curate) on Feb 23, 2005 at 22:11 UTC
|
| [reply] |
|
| [reply] |
Re: Survey of Surveys on HTML Templating systems
by holli (Abbot) on Feb 24, 2005 at 16:51 UTC
|
Just for completeness, i´d like to mention PLP, a creation of our fellow brother Juerd. I´ve never used it, but from what I´ve read it seems to be similar to PHP.
From the homepage:
PLP is yet another Perl embedder, primarily for HTML documents. Unlike with other Perl embedders, there is no need to learn a meta-syntax or object model: one can just use the normal Perl constructs. PLP runs under mod_perl for speeds comparable to those of PHP, but can also be run as a CGI script.
| [reply] |
Re: Survey of Surveys on HTML Templating systems
by pingo (Hermit) on Feb 24, 2005 at 14:02 UTC
|
This may be a bit off-topic, but does anyone know if there is a Velocity template parser for Perl? Velocity seems to be getting more and more popular in the Java world, and the templates doesn't look like they would be too hard to parse. :-) | [reply] |
Re: Survey of Surveys on HTML Templating systems
by Anonymous Monk on Feb 01, 2006 at 02:21 UTC
|
Nice writeup, overall. One nit:
Newbie is advised to have a look at Jeffa's tool for integration with Dreamweaver Templates (I think this advice was confused)
This advice was not confused. jeffa's Dreamweaver extension added support for HTML::Template style markup in Dreamweaver. It had nothing to do with Dreamweaver templates. | [reply] |
|
|