[Twisted-web] appropriate way to use patternGenerator
James Y Knight
foom at fuhm.net
Mon May 9 08:36:24 MDT 2005
On May 8, 2005, at 6:31 PM, Carl Shimer wrote:
> I spent the last couple of hours trying to get the nevow LivePage
> stuff to
> work. The problem was on this line of my code:
>
> Inevow.IQ(self.docFactory).patternGenerator('foo')
>
It sounds like you're doing things the hard way, but I don't quite
understand your description of what you want to do -- it's a bit too
abstract for me. Patterns are designed for use by the immediately
enclosing renderer, so they operate on the unrendered tree, not the
rendered tree.
This is how most pattern uses look. A renderer which uses them,
immediately enclosing the patterns themselves.
def render_boolean(self, ctx, data):
return IQ(ctx).allPatterns(data and 'true' or 'false')
<div n:data="foo" n:render="boolean">
<span n:pattern="true">True!</span>
<span n:pattern="false">False!</span>
</div>
Perhaps your use case would be better served by filling slots?
James
More information about the Twisted-web
mailing list