I've modified Html.tcl to take a little trick from xmlgen/htmlgen and
use it to good effect, after discussion with jima.
Currently, Html.tcl arranges that commands of the form <*> will generate
HTML, such that [<h1> id X "This is a header"] generates "<h1
id='X'>This is a header</h1>".
This works well for simple forms, but less well for things like <ul> or
<div> whose content may be complex HTML.
Following xmlgen/htmlgen, I've augmented Html so that it understands two
new forms:
[<tag+> id whatever {
This content will be passed through [subst] in the calling context
}]
and [<tag!> ...] which will treat its content as a script to be
evaluated in the calling context, whose value will then form the tag's
body/content.
This is useful for (say):
[<ul+> {
[<li> element1]
[<li> element2]
...
}
and removes the need for those quite ugly [subst] things you might see
in the code I've written.
HOWEVER ... there is a downside ...
Most of the <tag>s around expect the default behaviour, content is
unevaluated and literally included in the body of the generated <tag>,
but because this was spectacularly useless in the context of <head>,
<body> and <html>, they were treated specially, and act as <head+>,
<body+> and <html+> now act.
My question is: does anybody mind if I remove that special case, and
expect that all the <head>, <body>, <html> tags under Html.tcl now
require the trailing +?
It is cleaner and more consistent, now that I've realised there's a neat
way to provide the functionality, but it would require anyone using
[<head> ...] etc to change it to [<head+> ...] if they depend upon the
old behaviour.
Feedback please.
Colin.
On Sun, 24 Apr 2011 11:40:05 +1000
Colin McCormack <co...@chinix.com> wrote:
> My question is: does anybody mind if I remove that special case, and
> expect that all the <head>, <body>, <html> tags under Html.tcl now
> require the trailing +?
> It is cleaner and more consistent, now that I've realised there's a
> neat way to provide the functionality, but it would require anyone
> using [<head> ...] etc to change it to [<head+> ...] if they depend
> upon the old behaviour.
I think it's okay, and I wonder why hasn't it been done that way
before :) At least, I have never used this special behaviour.
--
WBR, Andrew