On 27 February 2013 17:16, Jonathan Vanasco <[email protected]> wrote:
> In mako templates, then it's just...
>
>     <li class="${request.NavTabs.home}">Home</li>
>     <li class="${request.NavTabs.about}">About</li>
>
> IIRC, tal allows for conditional attributes

In Chameleon, which implements its own dialect of TAL, we have the
pipe operator ("|"):

  ${request.NavTabs.home|nothing}

Meaning that if the first expression raises an exception, then we try
the next one and so forth.

But sometimes it makes more sense to use the ternary conditional operator:

  ${'active' if request.NavTabs.active else 'inactive'}

I think the pipe operator is best for things like:

  ${request.came_from|came_from|nothing}

Note that you can put whitespace around it if you want to.

\malthe

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to