[Checkins] SVN: Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/template.txt Added template integration tests for METAL macros.

Malthe Borch mborch at gmail.com
Mon Sep 22 12:03:45 EDT 2008


Log message for revision 91350:
  Added template integration tests for METAL macros.

Changed:
  U   Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/template.txt

-=-
Modified: Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/template.txt
===================================================================
--- Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/template.txt	2008-09-22 16:02:44 UTC (rev 91349)
+++ Sandbox/malthe/chameleon.zpt/src/chameleon/zpt/template.txt	2008-09-22 16:03:45 UTC (rev 91350)
@@ -32,3 +32,35 @@
   >>> t.filename.startswith(os.sep)
   True
 
+METAL template integration
+--------------------------
+
+Page templates expose macros in their ``macros`` attribute.
+
+  >>> main = PageTemplate("""\
+  ... <html xmlns="http://www.w3.org/1999/xhtml"
+  ...       xmlns:tal="http://xml.zope.org/namespaces/tal"
+  ...       xmlns:metal="http://xml.zope.org/namespaces/metal"
+  ...       metal:define-macro="master">
+  ...   <div metal:define-slot="content">
+  ...       I will be replaced
+  ...   </div>
+  ... </html>""")
+
+  >>> content = PageTemplate("""\
+  ... <div xmlns="http://www.w3.org/1999/xhtml"
+  ...      xmlns:tal="http://xml.zope.org/namespaces/tal"
+  ...      xmlns:metal="http://xml.zope.org/namespaces/metal"
+  ...      metal:use-macro="main.macros['master']">
+  ...   <div metal:fill-slot="content">
+  ...       I replace you.
+  ...   </div>
+  ... </div>""")
+
+  >>> print content(main=main)
+  <html>
+    <div>
+         I replace you.
+    </div>
+  </html>  
+  



More information about the Checkins mailing list