Use this tag in the same way as the standard HTML <a> tag.
If the prevpage or nextpage attributes are used then an href attribute will be generated that respectively selects the previous and next pages of the specified <al-for> iterator.
If the treeselect, treefold or treeellipsis attributes are used then an href attribute will be generated that respectively selects or opens/closes the current node, or expands the selected ellipsis of the specified <al-tree> iterator,
Refer to the documentation for the <al-input> tag on page
If the specified or generated HREF does not contain a '?' (which separates the path component from the query component) then the tag will further modify the HREF as follows.
If the HREF contains an '=' then the HREF is assumed to be a query component so it is prefixed by the value returned by the current_url() execution context method.
If the HREF does not contain an '=' then it is assumed to be a page identifier so it is transformed into a redirect url by the redirect_url() execution context method.
For example:
>>> import albatross >>> class Ctx(albatross.SimpleContext): ... def current_url(self): ... return 'magic' ... >>> ctx = Ctx('.') >>> albatross.Template(ctx, '<magic>', ''' ... <al-a nextpage="m">Next Page</al-a whitespace> ... ''').to_html(ctx) >>> ctx.flush_content() <a href="magic?nextpage,m=1">Next Page</a>
In the most simple form of the tag you can use it just to provide the host selector by using the standard href attribute.
>>> import albatross >>> class Ctx(albatross.SimpleContext): ... def current_url(self): ... return 'magic' ... >>> ctx = Ctx('.') >>> albatross.Template(ctx, '<magic>', ''' ... <al-a href="login=1">Login</al-a whitespace> ... ''').to_html(ctx) >>> ctx.flush_content() <a href="magic?login=1">Login</a>
Alternatively you can use the expr attribute to evaluate an expression that produces the output href attribute.
>>> import albatross >>> class Ctx(albatross.SimpleContext): ... def current_url(self): ... return 'magic' ... def redirect_url(self, loc): ... return 'here/%s' % loc ... >>> ctx = Ctx('.') >>> ctx.locals.name = 'eric' >>> albatross.Template(ctx, '<magic>', ''' ... <al-a expr="'login=%s' % name">Login</al-a whitespace> ... <al-a expr="'remote?login=%s' % name">Login</al-a whitespace> ... <al-a href="page">Login</al-a whitespace> ... ''').to_html(ctx) >>> ctx.flush_content() <a href="magic?login=eric">Login</a> <a href="remote?login=eric">Login</a> <a href="here/page">Login</a>