diff markup/template.py @ 90:c835e81c50af trunk

When an expression evaluates to a callable, it is called implicitly.
author cmlenz
date Wed, 19 Jul 2006 17:50:17 +0000
parents 80386d62814f
children 01d36818bb3d
line wrap: on
line diff
--- a/markup/template.py
+++ b/markup/template.py
@@ -273,26 +273,29 @@
     ...   <p py:def="echo(greeting, name='world')" class="message">
     ...     ${greeting}, ${name}!
     ...   </p>
-    ...   ${echo('hi', name='you')}
+    ...   ${echo('Hi', name='you')}
     ... </div>''')
     >>> print tmpl.generate(ctxt)
     <div>
       <p class="message">
-        hi, you!
+        Hi, you!
       </p>
     </div>
     
+    If a function does not require parameters, the parenthesis can be omitted
+    both when defining and when calling it:
+    
     >>> ctxt = Context(bar='Bye')
     >>> tmpl = Template('''<div xmlns:py="http://markup.edgewall.org/">
-    ...   <p py:def="echo(greeting, name='world')" class="message">
-    ...     ${greeting}, ${name}!
+    ...   <p py:def="helloworld" class="message">
+    ...     Hello, world!
     ...   </p>
-    ...   <div py:replace="echo('hello')"></div>
+    ...   ${helloworld}
     ... </div>''')
     >>> print tmpl.generate(ctxt)
     <div>
       <p class="message">
-        hello, world!
+        Hello, world!
       </p>
     </div>
     """
Copyright (C) 2012-2017 Edgewall Software