On Tue, 31 Oct 2006 16:38:22 +0200, kgi
On Tuesday 31 October 2006 15:12, Tristan Seligmann wrote:
* kgi
[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 ],
Results in:
<input type="text" class="sw-input" onkeypress="return Nevow.Athena.Widget.handleEvent(this, "onkeypress", "keyPressed");" />
Should I be wrapping it in anything else (T.raw()?).
Are you sure this is causing a problem? It looks correct to me. :)