[GOODIE] HTML Builder

Avi Bryant avi at beta4.com
Wed Jun 5 19:06:04 UTC 2002


On Wed, 5 Jun 2002, Stephen Pair wrote:

> Isn't a lot of this capability already available with the current HTML
> parse nodes in Scamper?  If not, couldn't you just enhance the HTML
> generation capabilities of the Scamper HTML parser classes?

Not really, no.  The point of the exercise, for me, was to come up with as
lightweight a syntax as possible for generating HTML - the rough
equivalent of a with-html macro in Lisp (which usually looks something
like
(with-html
  (:h1 'MyForm')
  (:form :action 'foo'
    (:input :type 'text')
    (if (use-submit-button)
       (:input :type 'submit)))))

It would be possible to have the HTMLBuilder output Scamper's HtmlEntity
nodes, but since all I need right now is to dump the html to a stream,
there didn't seem to be much point.

One reason to use the Scamper HtmlParser would be to use its knowledge of
HTML structure; however, this is pretty broken, and I'm not entirely
sure why (that is, whether by accident or by design).  For example, nested
forms are allowed but nested tables aren't, which is backwards:

HtmlForm new mayContain: HtmlForm new   "true"
HtmlTableDataItem new mayContain: HtmlTable new "false"

For Seaside we wrote a separate HTML parser that actually conforms to the
spec, rather than modifying Scamper's, because I assume Scamper takes
liberties for a reason - ie, to cope decently with badly formed HTML.

Avi




More information about the Squeak-dev mailing list