Mods to Html package

已查看 8 次
跳至第一个未读帖子

Colin McCormack

未读,
2011年4月23日 21:40:052011/4/23
收件人 Wub Discussion
Hi All,

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.


Andrew O. Shadoura

未读,
2011年4月24日 07:44:252011/4/24
收件人 wub-dis...@googlegroups.com
Hello,

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

signature.asc
回复全部
回复作者
转发
0 个新帖子