ANN: htmlgen and xmlgen, Writing HTML with Tcl 
Author Message
 ANN: htmlgen and xmlgen, Writing HTML with Tcl

Announcing packages
                          htmlgen and xmlgen
                             version 1.0

for easy and dynamic creation of HTML/XML with Tcl.

WHAT IS IT?

Inspired by recent discussions about namespacing cgi.tcl and the
difference between cgi.tcl and several packages in tcllib, I prepared
xmlgen and, on top of it htmlgen.

Similar to cgi.tcl, an XML tag is defined as a Tcl command. It prints
the opening tag, then executes its body argument and then prints the
closing tag. The body argument, being a script, will again contain
markup commands which behaves in the same way. In short, you write

  ul {
    li - one     ;# see the docs for the funny "-"
    li - two can have some [b bold]
  }

to get

  <ul>
    <li>one</li>
    <li>two can have some <b>bold</b></li>
  </ul>

Currently, xmlgen contains just one important command, namely
declartag which creates a proc for a tag. Package htmlgen builts on
that and declares all HTML tags as commands.

WHAT IT IS NOT!

In contrast to cgi.tcl, htmlgen does not contain any special knowledge
about individual HTML tags. In addition, it does not have CGI parsing,
because there is already package ::ncgi in tcllib.

WHERE TO GET?

There is no homepage yet, but for the time being it is available as

  http://www.*-*-*.com/

Note: It has nothing to do with bras, the `make' workalike for
Tcl. Its only that I don't have a good place to put the package.

Maybe people vote for this to go into tcllib?

Comments welcome,
  Harald Kirsch



Thu, 23 Sep 2004 21:04:31 GMT  
 ANN: htmlgen and xmlgen, Writing HTML with Tcl

Quote:

> Announcing packages
> htmlgen and xmlgen
> version 1.0

> for easy and dynamic creation of HTML/XML with Tcl.

Excellent work! This is a really neat abstraction which might even be an
improvement on the excellent cgi.tcl for html generation.  I would
certainly make use of this rather than ncgi which I found quite awkward.

The only thing that might be debated is the use of 'first character'
switches. Could this be modified to 'penultimate argument' switches eg.

h2 - Description
p  + {Some Stuff with [b extra markup]}
body bgcolor=red ! {
   p + {yada yada yada}

Quote:
}

ok so I guess this would break that rule...

h2 class=important - This is the title

so it would have to be the first param after the last x=y parameter.  

--
Steve Cassidy............SHLRC, Macquarie University, Sydney, Australia
...............<URL: http://www.shlrc.mq.edu.au/~steve>................



Fri, 24 Sep 2004 20:28:31 GMT  
 ANN: htmlgen and xmlgen, Writing HTML with Tcl

Quote:


> > Announcing packages
> > htmlgen and xmlgen
> > version 1.0

> > for easy and dynamic creation of HTML/XML with Tcl.

> Excellent work! This is a really neat abstraction which might even be an
> improvement on the excellent cgi.tcl for html generation.  I would
> certainly make use of this rather than ncgi which I found quite awkward.

Hmm, for what I did I found no obvious difference in input parsing
between ncgi and cgi.tcl (apart from the file upload problem reported
in other posts). What am I missing?

Quote:
> The only thing that might be debated is the use of 'first character'
> switches.

Agreed, it should be debated because I am really not yet decided.

Quote:
> Could this be modified to 'penultimate argument' switches eg.

> h2 - Description
> p  + {Some Stuff with [b extra markup]}
> body bgcolor=red ! {
>    p + {yada yada yada}
> }

> ok so I guess this would break that rule...

> h2 class=important - This is the title

> so it would have to be the first param after the last x=y parameter.  

So we have "first character of body" against "first argument after
attribute-value pairs". Which is better?

The main reason why I choose 'first char of body' was that I wanted to
have the frequent 'evaluate and print' case without any visible
overhead and at the same time have [b inline markup] without visible
overhead. Contrast

html {
  body {
    ul {
      li - bla
    }
  }

Quote:
}

with the forest of exclamation marks below:

html ! {
  body ! {
    ul ! {
      li - bla
    }
  }

Quote:
}

The first version requires the first char of the body to be a
controlling element.

On the other hand, when looking at the documentation I wrote with
htmlgen for htmlgen, I find myself using "{+..." twice as much as
"{\n...". In addition, an explicit argument is certainly a cleaner
solution on the implementation side, easier to extend in the future
and in the end might enhance long-term code readability.

Other arguments?

  Harald Kirsch.

--
----------------+------------------------------------------------------
Harald Kirsch   | kirschh bei lionbioscience punkt com
       *** Please do not send me copies of your posts. ***



Fri, 24 Sep 2004 21:52:18 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ANN: htmlgen and xmlgen 1.1

2. htmlgen and xmlgen 1.1

3. ANN: xmlgen-1.2.1

4. ANN: xmlgen-1.2 (overrides previous posting)

5. Hum, i want use htmlgen to generate html

6. htmllib, cgi, HTMLfmt, genCGI, HTMLgen, html, Zope, ...

7. HTML -> HTMLGen (or similiar)

8. xmlgen-1.4 --- Tcl as an XML authoring tool

9. Looking for an HTML Editor written in pure TCL/TK

10. LaTeX to HTML Converted written in TCL

11. Ann: Clipper/[x]Harbour Scripts in HTML and ASP pages (WScript too)

12. ANN: Programming Ruby HTML/XML V0.3

 

 
Powered by phpBB® Forum Software