Commits

Richard Shea  committed 1888dd9

Early version of the decorators demo

  • Participants
  • Parent commits 472da4a

Comments (0)

Files changed (1)

File dominate/examples/006-demo-build-document-decorators-simple.py

+'''
+Demonstration of using decorators to create DOM elements
+'''
+from dominate.document import document
+from dominate.tags import h2, h1, p, link, div
+
+
+@div
+def greeting(name):
+    p('Hello %s' % name)
+print greeting('Bob in greeting')
+
+print ""
+print ""
+print ""
+
+@div(h1('Welcome'), cls='greeting1')
+def greeting1(name):
+    p('Hello %s' % name)
+
+
+@div(h2('Welcome'), p("I am para 1"), p("I am para 2"), cls='greeting2')
+def greeting2(name):
+    p('Hello %s' % name)
+
+
+@div(cls='header')
+def header(name):
+    h2('i am the header')
+
+@div(cls='container')
+def container(name):
+    p('i am the container')
+
+@div(cls='footer')
+def footer(name):
+    p('i am the footer')
+
+@div(cls='container')
+def mybody(name):
+    header("X")
+    container("X")
+    footer("X")
+    
+
+
+'''
+print greeting1('Bob in greeting1')
+print greeting2('Bobette in greeting2')
+print greeting3('Fred in greeting3')
+'''
+print mybody("test")