|
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"
|