5.2.6.2 href="..." attributes

This attribute is ignored is any of the following attributes are present; prevpage, nextpage (5.2.6.4), treefold, treeselect, treeellipsis (5.2.6.5), or expr (5.2.6.1).

When the expr attribute is used, then generated value is processed in the same as a value supplied in the href attribute.

If the href does not contain a '?' (separates the path from the query), but does contain a '=' then the href is rewritten as current_url?href.

>>> 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>

If the href does not contain either a '?' or a '=' then the href is assumed to be a page identifier so it is transformed into a redirect url by the redirect_url() execution context method.

>>> 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>