If the name="..." is used, the tag becomes a named lookup and expansion is deferred until the lookup is referenced via the <al-value> element. In this case, the lookup is performed on the evaluated value of the <al-value> expr attribute.
For example:
>>> import albatross >>> ctx = albatross.SimpleContext('.') >>> MILD, MEDIUM, HOT = 0, 1, 2 >>> albatross.Template(ctx, '<magic>', ... '''<al-lookup name="curry"> ... <al-item expr="MILD">Mild <al-value expr="curry"></al-item> ... <al-item expr="MEDIUM">Medium <al-value expr="curry"></al-item> ... <al-item expr="HOT">Hot <al-value expr="curry"></al-item> ... </al-lookup>''').to_html(ctx) >>> ctx.locals.spicy = 2 >>> ctx.locals.curry = 'Vindaloo' >>> albatross.Template(ctx, '<magic>', ''' ... <al-value expr="spicy" lookup="curry" whitespace> ... ''').to_html(ctx) >>> ctx.flush_content() Hot Vindaloo
By placing lookup tables in separate template files you can eliminate redundant processing via the run_template_once() execution context method. This method is defined in the AppContext class that is used as a base for all application execution contexts.
As the above example demonstrates, you are able to place arbitrary template HTML inside the lookup items. As the content of the item is only executed when referenced, all expressions are evaluated in the context of the template HTML that references the item.