choose a template
am 18.06.2009 04:36:17 von Practical Perl
Hello,
We have a new project, which is medium large, with about 300 CGI
scripts with Perl.
We have designers who make HTML/JS/CSS etc. But designers don't know Perl.
I want to choose a template system which will separate Perl code from
front-page codes (like html,css etc).
I have the experience on using HTML::Template and Template::Toolkit.
HTML::Template is too simple, for example, if the programmer want to
generate a dynamic "select" form, the template can't handle it.
Template::Toolkit is smart enough, but it requires designners to know
some syntax about Perl.
So, is there any other good choice? Any suggestion are welcome. Thanks.
Jenn
Re: choose a template
am 18.06.2009 04:39:03 von Perrin Harkins
On Wed, Jun 17, 2009 at 10:36 PM, wrote:
> Template::Toolkit is smart enough, but it requires designners to know
> some syntax about Perl.
How so? I've often used TT with people who didn't know any perl. How
is it more difficult for them than HTML::Template is?
- Perrin
Re: choose a template
am 18.06.2009 05:37:06 von Practical Perl
I got the code piece from Template's manual:
my $vars =3D {
root =3D> 'http://here.com/there',
menu =3D> [ 'modules', 'authors', 'scripts' ],
client =3D> {
name =3D> 'Doctor Joseph von Satriani',
id =3D> 'JVSAT',
},
checkout =3D> sub { my $total =3D shift; ...; return $something },
shopcart =3D> My::Cool::Shopping::Cart->new(),
};
[% IF shopcart.nitems %]
Your shopping cart contains the following items:
[% FOREACH item =3D shopcart.contents %]
- [% item.name %] : [% item.qty %] @ [% item.price %]
[% END %]
[% checkout(shopcart.total) %]
[% ELSE %]
No items currently in shopping cart.
[% END %]
Here, aren't shopcart.nitems and shopcart.contents method calling of
an object like?
So I was thinking designers will be confused on them.
Thanks.
Jenn.
On Thu, Jun 18, 2009 at 10:39 AM, Perrin Harkins wrote:
> On Wed, Jun 17, 2009 at 10:36 PM, wrote:
>> Template::Toolkit is smart enough, but it requires designners to know
>> some syntax about Perl.
>
> How so? =A0I've often used TT with people who didn't know any perl. =A0Ho=
w
> is it more difficult for them than HTML::Template is?
>
> - Perrin
>
Re: choose a template
am 18.06.2009 05:50:07 von Perrin Harkins
On Wed, Jun 17, 2009 at 11:37 PM, wrote:
> Here, aren't shopcart.nitems and shopcart.contents method calling of
> an object like?
Yes. If you don't like passing objects, you could just pass the list
of items as an array of hashes. One nice thing about TT here is that
the syntax is the same.
> So I was thinking designers will be confused on them.
Whether you pass data or objects, you'll have to tell your designers
what they have to work with. This usually means writing some simple
documentation telling them what's available on the page.
I used to never pass objects, thinking it would lead to poor coding
practices in the templates. Sometimes it does, but it's very
convenient. My experience has been that anyone who can write HTML has
no trouble with the concept of a shopping cart object that has a list
of properties they can access.
- Perrin
Re: choose a template
am 18.06.2009 20:51:55 von Ronald J Kimball
On Thu, Jun 18, 2009 at 11:37:06AM +0800, practicalperl@gmail.com wrote:
> Here, aren't shopcart.nitems and shopcart.contents method calling of
> an object like?
> So I was thinking designers will be confused on them.
JavaScript has objects, and also uses dot syntax for accessing object
properties.
Ronald