[Twisted-web] How to render an empty stan tag in Nevow

Matt Goodall matt at pollenation.net
Tue Sep 27 16:13:23 MDT 2005

Pedro Sanchez wrote:

>I have a situation like this:
>class myPage(rend.Page):
>    def render_salute(self, context, data):
>	rv = <something-I-don't-know>
>        if <condition>:
>           rv = loaders.stan(T.p['You made it'])
>        return rv
>    docFactory = loaders.stan(
>	....
>	T.invisible(render=T.directive('salute'))
>        ....
>What I want in render_salute is to return 'nothing' if <condition> is
>false. Basically, as if the T.invisible in the docFactory didn't exist.
>I've tried
>  <something-I-don't-know> = loaders.stan(T.p[''])
>but it has the side effect of forcing a line break which is undesirable
>(in my real code the T.invisible is inside a table cell). Even returning
>a &nbsp; string would do it! 
>Any suggestions?
return ''

Semantically, "return None" is better but the Big Red None is such a
useful debugging aid that returning the emptry string is used to
indicate HTML nothingness.

- Matt

More information about the Twisted-web mailing list