[Twisted-web] How to insert an Athena event handler using Stan?
iacovou at gmail.com
Tue Oct 31 08:38:22 CST 2006
On Tuesday 31 October 2006 15:12, Tristan Seligmann wrote:
> * kgi <iacovou at gmail.com> [2006-10-31 11:58:35 +0200]:
> > However, if one has stan-based rather than file-based XHTML, it's neither
> > documented nor obvious how this should be done. I've managed to get this
> > far:
> > from nevow import stan
> > ...
> > _athena = stan.Proto (
> > 'athena:handler event="onkeypress" handler="keyPressed"'
> > )
> > ...
> > T.input ( type = "text", _class = "sw-input" ) [ _athena ]
> stan.Proto takes a tag name, so you would really want
> just stan.Proto('athena:handler'). However, there's already one of these
> in athena, so you can just do:
> from nevow import stan, athena
> # ...
> T.input(type='text', _class='sw-input')[
> athena.handler(event='onkeypress', handler='keypressed']
Thanks, Tristan; that's certainly a step forward: the tag is now being
recognised and replaced. However, it's not quite perfect yet: the generated
HTML is escaped:
_handler = athena.handler ( event = 'onkeypress', handler = 'keyPressed' )
T.input ( _class = "sw-input", type = "text" ) [ _handler ],
<input type="text" class="sw-input" onkeypress="return
Should I be wrapping it in anything else (T.raw()?).
More information about the Twisted-web