New submission from Kevin Kalupson <kjk...@psu.edu>:

The steps to repeat are to create two templates, one with a macro and slots and
one that is used to fill the slots in that template.  Both templates have an 
xml and
DOCTYPE declaration.  The issue is that the final rendered page ends up
having two xml declarations and two DOCTYPE declarations.

Attached is a patch that includes a modification to the doc test as well.

----------
files: chameleon.patch
messages: 342
nosy: kevin7kal
priority: bug
status: unread
title: Chameleon - multiple xml and doctype declarations in rendered templates 
with macros.

__________________________________
Repoze Bugs <b...@bugs.repoze.org>
<http://bugs.repoze.org/issue116>
__________________________________
Index: src/chameleon/core/translation.py
===================================================================
--- src/chameleon/core/translation.py	(revision 8075)
+++ src/chameleon/core/translation.py	(working copy)
@@ -978,7 +978,7 @@
             root = wrapper
 
         # output XML headers, if applicable
-        if not macro:
+        if global_scope is True:
             header = ""
             if self.xml_declaration is not None:
                 header += self.xml_declaration + '\n'
Index: src/chameleon/zpt/template.txt
===================================================================
--- src/chameleon/zpt/template.txt	(revision 8075)
+++ src/chameleon/zpt/template.txt	(working copy)
@@ -49,6 +49,8 @@
 macros, while ``template`` is always the template being executed.
 
   >>> main = PageTemplate("""\
+  ... <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+  ... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
   ... <html xmlns="http://www.w3.org/1999/xhtml";
   ...       xmlns:tal="http://xml.zope.org/namespaces/tal";
   ...       xmlns:metal="http://xml.zope.org/namespaces/metal";
@@ -69,6 +71,8 @@
   ... </html>""")
 
   >>> print main()
+  <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
   <html xmlns="http://www.w3.org/1999/xhtml";
         template-macros="master" macros="master">
      Who are you, foo?
@@ -92,6 +96,8 @@
   KeyError: 'bad_macro'
   
   >>> content = PageTemplate("""\
+  ... <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+  ... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
   ... <div xmlns="http://www.w3.org/1999/xhtml";
   ...      xmlns:tal="http://xml.zope.org/namespaces/tal";
   ...      xmlns:metal="http://xml.zope.org/namespaces/metal";
@@ -105,6 +111,8 @@
   ... </div>""")
 
   >>> print content(main=main, bar='bar')
+  <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
   <html xmlns="http://www.w3.org/1999/xhtml";
         template-macros="dummy" macros="master">
     Who are you, foo?
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to