5.2.2.6 nameexpr="..." attribute

###
5.2.2.6 `nameexpr="..."` attribute

This attribute is ignored if any of the following attributes are present; `prevpage`, `nextpage` (5.2.2.9), `treefold`, `treeselect`, `treeellipsis` (5.2.2.10), or `alias` (5.2.2.1).

The expression in the value of the `nameexpr` attribute is evaluated to determine the generated `name` (5.2.2.5) attribute.

One shortcoming of the `alias` attribute is that you can only perform input on object attributes. The `nameexpr` enables you to perform input on list elements.

    >>> import albatross
    >>> ctx = albatross.SimpleContext('.')
    >>> ctx.locals.names = ['John', 'Terry', 'Eric']
    >>> albatross.Template(ctx, '<magic>', '''
    ... <al-for iter="i" expr="range(len(names))">
    ...  <al-input nameexpr="'names[%d]' % i.value()" whitespace>
    ... </al-for>
    ... ''').to_html(ctx)
    >>> ctx.flush_content()
    <input name="names[0]" value="John" />
    <input name="names[1]" value="Terry" />
    <input name="names[2]" value="Eric" />

When the browser request is merged into the execution context the names elements of the `names` list will be replaced.