[Twisted-web] How to fill slots in sub-pattern
Paul Reznicek
maillists at ivsn.com
Sat Mar 18 11:38:57 CST 2006
In replay to my self - I found a way:
# ----------------------------------------------
def render_row(self, ctx, data):
ctx.fillSlots('first_column', data[0])
ctx.fillSlots('second_column', data[1])
return ctx.tag
def render_contentMain(self, ctx, data):
pat = inevow.IQ(ctx).onePattern('contentNews')
return pat(data=data)
# ----------------------------------------------
That's all !!!!!!!!!!!!!!!!!!
Nevow is great !!!!!!!!!!!!!!
Paul
Paul Reznicek wrote:
> Hi all,
>
> I've one page template and would like to use different pattern in different
> Page subclasses.
> A snipped of the template:
>
> # ----------------------------------------------
> <td class="main">
> <n:invisible n:render="contentMain" n:data="contentData">
> <table n:pattern="contentTable" n:render="sequence">
> <tr n:pattern="header">
> <th id="firstHeader">First Column</th>
> <th id="secondHeader">Second Column</th></tr>
> <tr n:pattern="item" n:render="row">
> <td><n:slot name="first_column" />data1</td>
> <td><n:slot name="second_column" />data2</td>
> </tr>
> </table>
>
> <table n:pattern="otherTableData" n:render="sequence">
> <tr n:pattern="header">
> <th id="firstHeader">Col 1</th>
> <th id="secondHeader">Col 2</th></tr>
> <th id="thirdHeader">Col 3</th></tr>
> <tr n:pattern="item" n:render="row">
> <td><n:slot name="first_column" />data1</td>
> <td><n:slot name="second_column" />data2</td>
> <td><n:slot name="third_column" />data3</td>
> </tr>
> </table>
> </n:invisible>
> </td>
> # ----------------------------------------------
>
> The renderer should work like this:
> # ----------------------------------------------
> def render_contentMain(self, ctx, data):
> patternHere = inevow.IQ(ctx).onePattern('contentTable')
> patternHere.fillSlots('first_column', data[0])
> patternHere.fillSlots('second_column', data[1])
> return patternHere.tag
> # ----------------------------------------------
>
> But this does not work ...
> Can somebody help me?
>
> Thanks in advance,
> Paul
>
>
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>
More information about the Twisted-web
mailing list