On Tue, 12 Nov 2002 21:31, Ian Bicking wrote:
> It looks like:
> from SimpleHTMLGen import html
> p = html.html(html.head(html.title('my page here')),
> html.body(html.h1('some heading'),
> html.p('a paragraph'),
> html.p('another paragraph'),
> html.table(cellspacing=2, cellpadding=3, border=1,
> c=[html.tr(html.td('top left'),
> html.td('top right')), html.tr(html.td('bottom left'), html.td('bottom
> right'))]) ))
> print p
Yikes! What a mess!
Well, I've updated my TagWriter class to allow much more readable code, and
give a fair measure of control.
For example:
from TagWriter import *
p = HTML(HEAD(TITLE('my page here')),
BODY(H1('some heading'),
P('a paragraph'),
TagParm('parm1'),
P('another paragraph'),
TABLE(attr(cellspacing='2', cellpadding='3', border='1'),
TR(TD('top left'), TD('top right')),
TR(TD('bottom left'), TD('bottom right')))
))
p.dump(parm1 = 'hi there\n')
Note the class 'TagParm' - this allows TagWriter to be used as a templates
library. Also the class 'attr' which is used to define tag attributes.
Also note that HTML, HEAD, BODY etc are each subclasses of TagWriter, which is
a subclass of HTMLTag
The class and the above demo are available from
http://www.freenet.org.nz/downloads/tagwriter.tgz
Phew! Now to add a mysql back end, and PHP-Nuke is history!
Cheers
David
>
> htmlgen seemed too complicated for me, where SimpleHTMLGen felt more
> predictable. But I'm really only using it for HTML contained in code,
> not entire pages.
>
> On Tue, 2002-11-12 at 01:50, David McNab wrote:
> > On Tue, 12 Nov 2002 20:36, Chuck Esterbrook wrote:
> > > Can you post an example of using HTMLTag for page generation?
> >
> > Hardly a live case, but I've put up a tarball of my TagWriter class, and
> > a demo of its use.
> >
> > http://www.freenet.org.nz/downloads/tagwriter.tgz
> >
> > Note that it's a work in process - I'm in the process of adding a scheme
> > for parameter substitution, so that TagWriter instances can be used as
> > templates.
> >
> > Cheers
> > David
> >
> > PS I've taken a lot of shit on #python for doing this. People seem to
> > think that only lamers use CGI for Python, and ignore any arguments that
> > commercial hosts with Zope are in the tiniest minority and are much mroe
> > expensive.
> >
> >
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by:ThinkGeek
> > Welcome to geek heaven.
> > http://thinkgeek.com/sf
> > _______________________________________________
> > Webware-discuss mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/webware-discuss
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Webware-discuss mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/webware-discuss
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss