You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by pr...@gmail.com on 2009/06/18 04:36:17 UTC

choose a template

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

Posted by Perrin Harkins <ph...@gmail.com>.
On Wed, Jun 17, 2009 at 11:37 PM, <pr...@gmail.com> 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

Posted by Ronald J Kimball <rj...@tamias.net>.
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

Re: choose a template

Posted by pr...@gmail.com.
I got the code piece from  Template's manual:

    my $vars = {
        root   => 'http://here.com/there',
        menu   => [ 'modules', 'authors', 'scripts' ],
        client => {
            name => 'Doctor Joseph von Satriani',
            id   => 'JVSAT',
        },
        checkout => sub { my $total = shift; ...; return $something },
        shopcart => My::Cool::Shopping::Cart->new(),
    };


    [% IF shopcart.nitems %]
       Your shopping cart contains the following items:
       <ul>
       [% FOREACH item = shopcart.contents %]
         <li>[% item.name %] : [% item.qty %] @ [% item.price %]
       [% END %]
       </ul>

       [% 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<ph...@gmail.com> wrote:
> On Wed, Jun 17, 2009 at 10:36 PM, <pr...@gmail.com> 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

Posted by Perrin Harkins <ph...@gmail.com>.
On Wed, Jun 17, 2009 at 10:36 PM, <pr...@gmail.com> 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