def mobile_template(template):
def decorator(f):<EOL><INDENT>@functools.wraps(f)<EOL>def wrapper(*args, **kwargs):<EOL><INDENT>ctx = stack.top<EOL>if ctx is not None and hasattr(ctx, '<STR_LIT>'):<EOL><INDENT>request = ctx.request<EOL>is_mobile = getattr(request, '<STR_LIT>', None)<EOL>kwargs['<STR_LIT>'] = re.sub(r'<STR_LIT>',<EOL>r'<STR_LIT>' if is_mobile else '<STR_LIT>',<EOL>template)<EOL><DEDENT>return f(*args, **kwargs)<EOL><DEDENT>return wrapper<EOL><DEDENT>return decorator<EOL>
Mark a function as mobile-ready and pass a mobile template if MOBILE.

For example::

    @mobile_template('a/{mobile/}b.html')
    def view(template=None):
        ...


if ``request.MOBILE=True`` the template will be `a/mobile/b.html`.
if ``request.MOBILE=False`` the template will be `a/b.html`.

This function is useful if the mobile view uses the same context but a
different template.