[albatross-users] complete newbie al-for / template problem....

Andrew McNamara andrewm at object-craft.com.au
Fri Sep 13 19:39:49 EST 2002


>That looks like it.  It seems the template parser thinggy is much more
>limited than I might haver expected.  (I don't remember reading anything
>that warned against this sort of thing, but perhaps this is assumed XML
>knowledge?)

More likely we've just overlooked documenting it! 8-)

The template parser is a huge regular expression - the downside is that
it will overlook things that aren't correctly structured - the upside is
that it will overlook everything but albatross tags (this is important
for performance - if we used a real XML parser, we'd have to build an
enourmous tree of every HTML tag, which, in python, would really bite).
It also means that the user can be lazy in their pure-HTML mark-up
without Albatross choking.

>Some other ways I have tricked it:
>	<al-for iter="f", expr="alist">	(note the bogus comma)

That's asking for it! 8-)

>	<al-for iter="f" expr='''
>		( 1, 2, 3,  # Lots and lots more
>		4, 5, 6
>		)
>		'''> (which seems reasonable from a python programmer's viewpoint!)

We could, in fact, relatively easily extend the parsing regexp to
handle this. But an XML editor would probably choke (not that we're 100%
correct with our XML at the moment - things like <al-else> really should
be <al-else /> (this does work)).

>These both gave an unhelpful message about "</al-for> not expected".

Because the start tag wasn't recognised by the regexp.

>Also:
>	<al-input type="text" name="aname" size=10> 
>		(note the missing "" around the size arg)
>which caused the al-input tag to be passed through the template expansion 
>verbatim, even tho this seems to work in raw HTML.

Yep - I suspect the regexp is again not seeing the attribute. XHTML
explicitly disallows unquoted attributes.

>Not bad for a couple of hours fiddling!

Indeed - it's good having a fresh set of eyes over the code - you pick up
many things that we miss. Keep the reports coming... 8-)

>So this comes to a suggestion: add a section to the manual to explain that
>the tag format is very picky and must be properly-formated XML.

Good idea.

>And a complete aside: has anyone looked at an Xemacs XML editing mode that
>knows the albatross tags?

That would be question for Dave, I think - he uses emacs more regularly
than me.

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/



More information about the Albatross-users mailing list