Skip to content

Instantly share code, notes, and snippets.

@colwilson
Created January 12, 2013 12:52
Show Gist options
  • Save colwilson/4517977 to your computer and use it in GitHub Desktop.
Save colwilson/4517977 to your computer and use it in GitHub Desktop.
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