Click here to get back home

I don't want to write an HTML templating module

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
I don't want to write an HTML templating module Hayden Stainsby 08-30-2007
Posted by Hayden Stainsby on August 30, 2007, 5:27 am
Please log in for more thread options


Like many Perl developers at one stage or another I'm thinking of
writing an HTML templating module. Of course I know this is a bad
idea, there's plenty of really good ones about. I don't want to, so...

Are there any Perl modules about that do HTML templating like Apache's
Tapestry for Java? Specifically a way of doing HTML templating that
keeps your HTML completely separate from your code. So there's no code
in the template at all, but rather the module reads the template and
then uses it to format the data it has.

The main advantage for this is that a designer who knows (and wants to
know) nothing of programming can create the template, and the
programmer can write the code and crossover between these two tasks
can be mostly removed.

Thanks.

--
Hayden

--
I'm trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.malcom-mac.com/nemo


Posted by Gunnar Hjalmarsson on August 30, 2007, 5:58 am
Please log in for more thread options


Hayden Stainsby wrote:
> Are there any Perl modules about that do HTML templating

http://search.cpan.org/search?query=HTML+template

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Posted by Hayden Stainsby on August 30, 2007, 6:35 am
Please log in for more thread options


> Hayden Stainsby wrote:
>> Are there any Perl modules about that do HTML templating

> http://search.cpan.org/search?query=HTML+template

I'm sorry for not making my aims more specific. I'm looking for a
system that allows a template to contain nothing that isn't HTML,
basically a page that can be rendered by a web browser - more an
example page in static HTML than a template in some ways. So there
aren't any control structures in the HTML - tapestry uses a few (not
strictly HTML) attribute such as 'jwcid' in some tags so they can be
referenced later.

So an HTML template snippet like this:

<ul>
<li jwcid="list_item">Jackets</li>
<li jwcid="list_item">Shirts</li>
<li jwcid="list_item">Ties</li>
</ul>

Could be linked to a Perl array via it's id 'list_item':

qw(Cars Planes Boats Boats Space-ships)

and an output like (the non-html jwcid attribute is removed):

<ul>
<li>Cars</li>
<li>Planes</li>
<li>Boats</li>
<li>Boats</li>
<li>Space-ships</li>
</ul>

I've looked through pretty much every html templating release on CPAN
and can't find anything myself, which is why I'm asking here.

Thanks.

--
Hayden

--
I'm trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.malcom-mac.com/nemo


Posted by Randal L. Schwartz on August 30, 2007, 10:59 am
Please log in for more thread options



Hayden> I'm sorry for not making my aims more specific. I'm looking for a
Hayden> system that allows a template to contain nothing that isn't HTML,
Hayden> basically a page that can be rendered by a web browser - more an
Hayden> example page in static HTML than a template in some ways. So there
Hayden> aren't any control structures in the HTML - tapestry uses a few (not
Hayden> strictly HTML) attribute such as 'jwcid' in some tags so they can be
Hayden> referenced later.

And that makes it not HTML. If you're already crossing the line, cross
it completely. Don't pretend you're not crossing it. :)

Hayden> So an HTML template snippet like this:

Hayden> <ul>
Hayden> <li jwcid="list_item">Jackets</li>
Hayden> <li jwcid="list_item">Shirts</li>
Hayden> <li jwcid="list_item">Ties</li>
Hayden> </ul>

And that's not HTML. You might as well write:

[% list = ['Jackets' 'Shirts' 'Ties'] %]
[% FOR item IN list %]
[% "<ul>" IF loop.first %]
<li> [% item %] </li>
[% "</ul>" IF loop.last %]
[% END # foreach %]

And life is good. :-)

print "Just another Perl hacker,"; # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

--
Posted via a free Usenet account from http://www.teranews.com


Posted by Hayden Stainsby on August 30, 2007, 12:40 pm
Please log in for more thread options


merlyn@stonehenge.com(Randal L. Schwartz) wrote:
> And that makes it not HTML. If you're already crossing the line,
> crossit completely. Don't pretend you're not crossing it. :)

There's still a big difference between what I have below, which will
display correctly most browsers and can be passed around as an example
of what a page will look like, and what's required when you have code
(even if it isn't perl code) inside the HTML.

I can give the former to anyone who knows HTML - or anyone who can
operate Dreamweaver - and they can edit it happily without knowing
what these extra attributes mean. The second however can only be
editted by someone who knows the syntax for HTML::Template - or
another templating module which works in a similar fashion.
> Hayden> So an HTML template snippet like this:

> Hayden> <ul>
> Hayden> <li jwcid="list_item">Jackets</li>
> Hayden> <li jwcid="list_item">Shirts</li>
> Hayden> <li jwcid="list_item">Ties</li>
> Hayden> </ul>

> And that's not HTML. You might as well write:

> [% list = ['Jackets' 'Shirts' 'Ties'] %]
> [% FOR item IN list %]
> [% "<ul>" IF loop.first %]
> <li> [% item %] </li>
> [% "</ul>" IF loop.last %]
> [% END # foreach %]

But thanks for pointing out my stepping over lines and such. (-:

--
I'm trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.malcom-mac.com/nemo


Similar ThreadsPosted
Best HTML Templating Module July 17, 2005, 6:04 pm
Request for naming help (templating module) September 8, 2005, 11:34 pm
write a new module for suffix trees? April 3, 2008, 5:12 pm
"reverse templating" or "auto-meta-regex" module for automated screen-scrape learning? September 18, 2007, 10:09 pm
[RFC] Data::Endian (proposal for module to read/write big-endian floats/doubles) July 3, 2007, 5:26 pm
SerialPort write question October 28, 2004, 11:52 am
Tie::YAML doesn't write to tmp file first? December 23, 2007, 9:34 am
How to write into existing Excel Spreadsheets? July 13, 2004, 1:24 pm
Can I write Macros in excel workbook ? October 8, 2004, 7:50 am
Namespace for new module: HTML::Template::HTX? May 13, 2005, 7:17 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap