How omit piece of master template from showing up in *some* slave templates?

2 views
Skip to first unread message

sebe...@spawar.navy.mil

unread,
Dec 2, 2006, 3:47:40 PM12/2/06
to TurboGears
How omit piece of master template from showing up in *some* slave
templates?

Specifically, I don't want a certain menu to show up in 2 slave
templates.

I'm guessing conditional code is way to go but I don't know if
conditional code

should go in master or slave template.

Any help greatly appreciated.

Chris

Patrick Lewis

unread,
Dec 3, 2006, 3:18:12 AM12/3/06
to TurboGears
One option is something like (in the master):

<div py:strip="value_of('hide_div')">I won't show up if hide_div is
true.</div>

Then have the controller add {'hide_div':True} to the returned dict in
cases where you don't want to show the content.

Another option is to use css {display:none} in the slave to always hide
the element. That still puts the content in the HTML source, and might
not work if the data is sensitive (or in browsers that don't handle
CSS). On the plus side, it's easy to implement.

Elvelind Grandin

unread,
Dec 3, 2006, 7:22:30 AM12/3/06
to turbo...@googlegroups.com
Use py:match (http://kid-templating.org/language.html#match-templates-py-match)
basicly something like this:

master:
<span py:match="item.tag == 'menu'"> <the menu> </span>
slave:
<menu />


--
cheers
elvelind grandin

Reply all
Reply to author
Forward
0 new messages