[albatross-users] XML and Albatross templates?

Andrew McNamara andrewm at object-craft.com.au
Thu May 5 12:51:23 EST 2005


As people are probably aware, some aspects of Albatross templating prevent
XML validation of the source - specifically the <al-else> tag:

    <al-if expr="..."> ...  <al-else> ...  </al-if>

There's no way to balance that <al-else> (normally empty tags would be
written <al-else/>, but that doesn't reflect what's happening here).

One option is to deprecate <al-if> (or <al-else>, at least), favouring an
inline version of <al-lookup> - for example:

    <al-lookup expr="...">
        <al-item expr="...."> abc </al-item>
        <al-item expr="...."> def </al-item>
        ghi
    </al-lookup>

This is quite a bit more verbose, but many of the cases where <al-if>
would formerly have been used are now better written using the "anytag"
structure. "Anytag" (which appears in the development prerelease [1])
allows any tag to be prefixed with "al-". When that is done, attributes
can selectively be the product of a python expression. For example:

    <table>
        <al-for iter="i" expr="stuff">
            <al-tr al-class="i.value().get_style()">
                    ....
            </al-tr>
        </al-for>
    </table>

Note that this also means that albatross tags within html tags are no
longer necessary. So this horrible contruct should be a thing of the past:

    <td colspan="<al-value expr='n.span()'>">

This is now written:

    <al-td al-colspan="n.span()">

Thoughts on the al-else thing? Why is XML validation important? At
some point we may wish to switch to an XML-based parser (rather than
the current regexp-based parser) - correct XML structure would make
this easier.

[1] http://www.object-craft.com.au/projects/albatross/download/albatross-1.30-dev-20050301.tar.gz

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



More information about the Albatross-users mailing list