5.3.8.1 name="..." attribute
Description: name=
Keywords: albatross

###
5.3.8.1 `name="..."` attribute

The `name` attribute is used to uniquely identify the lookup table in the application. Other template HTML accesses the lookup table via the `<al-value>` (5.3.5) tag.

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.