5.3.10.1 expr="..." attribute

The expr attribute defines an expression that is evaluated to generate a lookup table key for the parent <al-lookup> (5.3.9) tag. When the parent <al-lookup> is executed all of the expr expressions are evaluated to build a dictionary of items.

For example:

>>> import albatross
>>> ctx = albatross.SimpleContext('.')
>>> ctx.locals.key = 2
>>> albatross.Template(ctx, '<magic>',
... '''<al-lookup name="look">
... <al-item expr="1">item expr="1" key is <al-value expr="key"></al-item>
... <al-item expr="key">item expr="key" key is <al-value expr="key"></al-item>
... </al-lookup>''').to_html(ctx)
>>> ctx.locals.key = 1
>>> t = albatross.Template(ctx, '<magic>', '''
... <al-value expr="key" lookup="look" whitespace>
... ''')
>>> t.to_html(ctx)
>>> ctx.flush_content()
item expr="1" key is 1
>>> ctx.locals.key = 2
>>> t.to_html(ctx)
>>> ctx.flush_content()
item expr="key" key is 2