Created
January 12, 2013 12:52
-
-
Save colwilson/4517977 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nagare import presentation | |
class Counter(object): | |
def __init__(self): | |
self.val = 0 | |
def increase(self): | |
self.val += 1 | |
def decrease(self): | |
self.val -= 1 | |
@presentation.render_for(Counter) | |
def render(counter, h, *args): | |
h << h.div('Value: ', counter.val) | |
# action method allows to register callbacks on HTML elements | |
# that can have actions (links, inputs, etc.) | |
h << h.a('++').action(counter.increase) | |
h << '|' | |
h << h.a('--').action(counter.decrease) | |
return h.root | |
app = Counter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment