On Thu, 27 Jul 2000, Ian Kallen wrote:
> Why the heck do we need more programming languages?  I understand people
> think they're performing some kind of service by cooking up something that
> looks simple for non-programmers but it looks more like hamstringing to 
> me, no thanks.  I'm impressed with Wardley's analysis of the problem in
> the proceeding of the Perl conference but his solution looks unappealing 
> to me: a language that is Perl yet it's not, ugh!

When I was deciding what to use for a project recently, I wrote out the
same short exmaple in the syntax of a few different templating systems.  
I'll include the example below.  I tried to be make it as clean as
possible and use whatever mechanisms each system provided for making
things easy on the HTML coders (who are not the perl programmers in my
case).  I even did some things in the name of readability that I might not
really do for performance reasons, like using accessor methods in the
Mason example rather than straight hash refs.

I think it shows some of the difficulty that your average HTML'er will
have with in-line perl.  You may not love Andy's TT syntax, but it makes a
lot of sense to people with a smattering of javascript who don't know
anything about perl references, etc.  The difference here isn't huge, but
it was enough to make me choose TT for this project.

One of my goals is to eventually produce a site which will have commentary
and examples of the various templating options for mod_perl (and maybe
java servlets as well).  I think it would be helpful to newbies who don't
want to slog through the hundreds of search returns on CPAN.

- Perrin

mini-language (using a system I built):

<?use type=product sku=bar1234?>
<?if product.isbn?>
  It's a book!
<?/if?>
<?ifnot product.isbn?>
  It's NOT a book!
<?/ifnot?>

<?loop product.related?>
  You might also enjoy <?val item.name?>.
<?/loop?>

<?inc footer?>


mini-language (Template Toolkit style):

[% USE product(sku=bar1234) %]
[% IF product.isbn %]
  It's a book!
[% ELSE %]
  It's NOT a book!
[% END %]

[% FOREACH item = product.related %]
  You might also enjoy [% item.name %].
[% END %]

[% INCLUDE misc/footer %]


in-line Perl (Mason style):

% if ($product->isbn) {
  It's a book!
% } else {
  It's NOT a book!
% }

% foreach my $item (@{$product->related}) {
  You might also enjoy <% $item->name %>.
% }

<& misc/footer &>

<%perl_init>
my $product = get('Product', 'sku' => 'bar1234');
<%/perl_init>


in-line Perl (ePerl style):

<: my $product = get('Product', 'sku' => 'bar1234'); :>
<: if ($product->isbn) { :>
  It's a book!
<: } else { :>
  It's NOT a book!
<: } :>

<: foreach my $item (@{$product->related}) { :>
  You might also enjoy <: $item->name :>.
<: } :>

<: include('misc/footer'); :>

Reply via email to