5.2.4.1 selected attribute
Description: selected attribute
Keywords: albatross

###
5.2.4.1 `selected` attribute

When generating the `<option>` tag the presence of a `selected` attribute is controlled by the comparison value from the enclosing `<al-select>` (5.2.3) tag. The comparison value is compared with the value of the `<al-option>` tag.

The value of the `<al-option>` tag is specified either in a `value` (5.2.4.2) attribute, or if that attribute is not present, by the content enclosed by the `<al-option>` tag. The enclosed content of the tag is evaluated before it is compared. This allows the content to be generated using other Albatross tags.

For example -- this shows how the `<al-option>` content is evaluated before it is compared with the `<al-select>` value:

    >>> import albatross
    >>> ctx = albatross.SimpleContext('.')
    >>> ctx.locals.opt = 'spam'
    >>> ctx.locals.sel = 'spam'
    >>> albatross.Template(ctx, '<magic>', '''
    ... <al-select name="sel">
    ...  <al-option><al-value expr="opt"></al-option>
    ...  <al-option>eggs</al-option>
    ... </al-select whitespace>
    ... ''').to_html(ctx)
    >>> ctx.flush_content()
    <select name="sel"><option selected>spam</option><option>eggs</option></select>