Commits

Rick Copeland committed 398f8fd

Fix weird bug when py:extends used as an attribute

Comments (0)

Files changed (4)

-* Make py:extends work even when it's not bare (or get better semantics for when it's not)
 * XML dynamic extends
 * XML blocks
 * XML closures

fastpt/tests/v2/test_xml.py

 <h6>Footer</h6>
 </div>''', rsp
 
-
 if __name__ == '__main__':
     main()

fastpt/v2/template.py

             raise
 
     def _extend(self, parent):
-        print 'Extends %s' % parent
         if isinstance(parent, basestring):
             parent = self.loader.import_(parent)
         p_inst = parent(self._context)

fastpt/v2/xml_template.py

         defs = [ ir.DefNode(k, *v) for k,v in self.functions.iteritems() ]
         return ir.TemplateNode(self.mod_py, defs)
 
-
     def _compile_node(self, node):
         if isinstance(node, dom.Comment):
             return self._compile_comment(node)
             tree.tagName,
             tree.getAttribute(QDIRECTIVES_DICT[tree.tagName]))
         tree.tagName = 'py:nop'
+    if tree.tagName != 'py:nop' and tree.hasAttribute('py:extends'):
+        import pdb; pdb.set_trace()
+        value = tree.getAttribute('py:extends')
+        el = tree.ownerDocument.createElement('py:extends')
+        el.setAttribute('href', value)
+        el.lineno = tree.lineno
+        tree.removeAttribute('py:extends')
+        tree.childNodes.insert(0, el)
     for directive, attr in QDIRECTIVES:
         if not tree.hasAttribute(directive): continue
         value = tree.getAttribute(directive)