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 xhoster on August 30, 2007, 1:02 pm
Please log in for more thread options


merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>
> 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.


Both of the HTML renders I've viewed it with managed to render it. Does
the HTML standard declare unrecognized attributes to be illegal?



> If you're already crossing the line, cross
> it completely. Don't pretend you're not crossing it. :)

Or we could just have modules that DWIM, rather than being
fundamentalist/extremist.

>
> 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. :-)

Eh, I see a big difference between those. And I'd much rather write
the first rather than the second.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB

Posted by Randal L. Schwartz on August 31, 2007, 1:44 am
Please log in for more thread options



xhoster> Both of the HTML renders I've viewed it with managed to render it. Does
xhoster> the HTML standard declare unrecognized attributes to be illegal?

Yes.

--
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 Peter J. Holzer on August 31, 2007, 2:43 pm
Please log in for more thread options


> merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>>
>> 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.
>
>
> Both of the HTML renders I've viewed it with managed to render it. Does
> the HTML standard declare unrecognized attributes to be illegal?

Yes, but

* There has always been an understanding that HTML processing programs,
in particular user agents, should cope gracefully with errors and
extensions. For example, the HTML 4.01 recommendation says this:

| B.1 Notes on invalid documents
|
| This specification does not define how conforming user agents handle
| general error conditions, including how user agents behave when they
| encounter elements, attributes, attribute values, or entities not
| specified in this document.
|
| However, to facilitate experimentation and interoperability between
| implementations of various versions of HTML, we recommend the following
| behavior:
|
| * If a user agent encounters an element it does not recognize, it
| should try to render the element's content.
| * If a user agent encounters an attribute it does not recognize, it
| should ignore the entire attribute specification (i.e., the
| attribute and its value).
| * If a user agent encounters an attribute value it doesn't
| recognize, it should use the default attribute value.
| * If it encounters an undeclared entity, the entity should be
| treated as character data.
|
| We also recommend that user agents provide support for notifying the
| user of such errors.

The first point is actually quite hard to implement: If you don't know
an element, you don't know what its content is. But attributes are
syntactically unambiguous, so the only programs likely to choke on
undefined attributes are validators (that's what they are there for).

* You aren't writing HTML, you are writing input for a template engine.
So there is no reason why the files you are writing need to conform to
HTML. They only need to be acceptable to your template engine and to
your authoring tools.


>> 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. :-)

If that's your idea of a good life, I don't want to know what you
consider a bad life.


> Eh, I see a big difference between those. And I'd much rather write
> the first rather than the second.

Same here.

        hp


--
_ | Peter J. Holzer | I know I'd be respectful of a pirate
|_|_) | Sysadmin WSR | with an emu on his shoulder.
| | | hjp@hjp.at |
__/ | http://www.hjp.at/ |        -- Sam in "Freefall"

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