[albatross-users] Re: Python embedded like PHP

Ian Bicking ianb at colorstudy.com
Sat Mar 23 05:45:50 EST 2002


On Thu, 2002-03-21 at 18:37, Andrew McNamara wrote: 
> >> The intention is that Albatross templates be valid XML - while Albatross
> >> will do the expected thing in the example you give above, it generally
> >> provides a "better" way, such as:
> >> 
> >>         <al-img expr="something">
> >
> >Do you mean that you have a template tag for every kind of tag for which
> >you would want to modify an attribute?  That's every single HTML tag --
> >IMG is hardly the only one.  A dynamic CSS class attribute, for
> >instance, or events (onMouseOver, etc), id tags, background colors...
> >there's a million possibilities.
> 
> No, we don't, although we're considering some options (such as abusing
> the XML namespace - for example: <al-img expr:src="something"> - thoughts?

I assume you are thinking that any al-* tag that isn't otherwise defined
would turn into a plain tag?  So you'd do 
<al-table expr:bgcolor="something"> ?  Seems kind of unXMLish as well. 

You could do something like: 

  <al-attr name="bgcolor" expr="something"><table>...</table></al-attr> 

That's very long, and you have to parse the entire document (I'm not
sure if you are doing that now).  Actually, it looks horrible and if I
was using such a language I would hate you.  Maybe: 

  <al-attr name="bgcolor" expr="something"/><table>...</table> 

I'm not sure if that's quite kosher or not... I guess there's nothing
really wrong about it, it just doesn't feel much like XML -- something
about binding two elements together when they are only next to each
other, not contained, seems odd.  And it still isn't pretty.

Of course there's the ZPT approach, which isn't bad, but then you might
as well use ZPT.  But I guess there's no reason you can't use something
like ZPT just for changing attributes, like: 

  <table al:bgcolor="something"> 

And then skip all the looping and such that ZPT does with attributes. 
You'd still have the worry about generating CSS and Javascript, though. 
Dave mentioned performance... doing a full XML parse is
performance-intensive, but you could fake it for this particular case --
you don't need to find the </table> tag or anything, you could probably
do it just with regexes.


I still think it's so much easier to use [], and make the system
orthogonal to XML or any other medium you might want to generate.  I
think it actually gives you better tool support as well.  

  Ian





More information about the Albatross-users mailing list