<%! class IndexPlaceHolderView: def on_init(self): self.name = '' def test_action(self, text,*args): print(text,args) self.element('header').set('text',f'hello javascript! text was {text} args were {args}') view_class = IndexPlaceHolderView %> <%inherit file="view.html"/>

WKApp index.html placeholder

To replace this placeholder simply create a file `views/index.html`, then add your html and setup a `view_class` mixin. An instance is created and maintained automatically for holding state, listening on view lifecycle events and two way interop between python and client-side javascript, providing element/DOM manipulation and wide flexibility to customise view/page behaviour. A simple view example:

Hello World!


% if view.name != '':

Hello ${view.name}!

% endif
${codeblock(""" <%! class MyFirstView: def on_init(self): self.name = '' def test_action(self, text,*args): print(text,args) self.element('header').set('text',f'hello javascript! text was {text} args were {args}') view_class = MyFirstView %> <%inherit file="view.html"/>

Hello World!


% if view.name != '':

Hello ${view.name}!

% endif
""")}

<%def name="codeblock(text, rows=0)"> <% if rows == 0: rows = text.count("\n")+1 %>