[albatross-users] al-values inside al-input

Dave Cole djc at object-craft.com.au
Fri Jan 31 10:50:28 EST 2003


>>>>> "Gregory" == Gregory Bond <gnb at itga.com.au> writes:

>> The problem is that you cannot use Albatross tags to construct
>> other Albatross tags.

Gregory> I wonder if it's possible to automatically support a fooexpr
Gregory> attribute for every foo attribute?  As I mentioned to Mike,
Gregory> most times you need to do this there is a fooexpr you can
Gregory> use, but not always....

Andrew and I have been tossing around ideas along these lines for a
while now (probably over a year).  We are on our second major
variation now.  We still haven't decided whether it would be a good
idea or not.

Short description of the way the parser works::

    The parser is regex based.  It looks for tags which start with
    '<al-' or '<alx-'.  When the parser finds a tag it performs a
    lookup on the tag name to find the class which implements the
    behaviour of that tag.

    Anything which is not recognised as an Albatross tag is processed
    as plain text.

Our current thinking for fooexpr like processing is something like
this::

* Implement a generic tag class to handle all tags that are not
  currently Albatross tags.  This would allow you to start placing
  tags like <al-td>blah blah</al-td> into your templates.  The parser
  would see the '<al-' prefix and map the tag onto the generic tag.
  
* Inside Albatross tags we would implement functionality which
  processes any attribute which is prefixed by 'al-' as a Python
  expression.

This would mean that most of the nameexpr, valueexpr, fooexpr stuff
would disappear and would be replaced by generic al-name, al-value,
al-foo attributes.

There are some issues with this approach, but nothing which cannot be
worked around (I think).

* Not all HTML tags enclose content, how would be know the difference
  in the parser?  Would we just create a register of all HTML content
  enclosing tags?

  In the first instance I would say no.

  Since we are only trying to provide a generic mechanism for
  providing attribute values we do not need to control enclosed
  content.  This means that we could treat the generic tag as a non
  content enclosing tag and simply transform close tags (for generic
  tags) when we see them.

  This leads to the following being valid, but do we care?

        <al-tr al-class="expr">
          <td>blah blah</td>
          <td>blah blah</td>
        </tr>

* What do we do when the enclosed expression returns None?

  I say we just suppress the attribute in the output.  So the above
  would be:

        <tr>
          <td>blah blah</td>
          <td>blah blah</td>
        </tr>

  rather than:

        <tr class="">
          :
  or:

        <tr class="None">
          :

  or:

        <tr class>
          :

- Dave

-- 
http://www.object-craft.com.au




More information about the Albatross-users mailing list