[Checkins] SVN: Sandbox/malthe/chameleon.genshi/ Expose text templates through the template loader

Wichert Akkerman wichert at wiggy.net
Thu Nov 13 13:52:23 EST 2008


Log message for revision 92913:
  Expose text templates through the template loader

Changed:
  U   Sandbox/malthe/chameleon.genshi/CHANGES.txt
  U   Sandbox/malthe/chameleon.genshi/src/chameleon/genshi/loader.py

-=-
Modified: Sandbox/malthe/chameleon.genshi/CHANGES.txt
===================================================================
--- Sandbox/malthe/chameleon.genshi/CHANGES.txt	2008-11-13 18:23:15 UTC (rev 92912)
+++ Sandbox/malthe/chameleon.genshi/CHANGES.txt	2008-11-13 18:52:23 UTC (rev 92913)
@@ -4,7 +4,7 @@
 head
 ~~~~
 
-- Added text template classes. [malthe]
+- Added text template classes. [malthe, wichert]
 
 - Added default element to parser class. [malthe]
 

Modified: Sandbox/malthe/chameleon.genshi/src/chameleon/genshi/loader.py
===================================================================
--- Sandbox/malthe/chameleon.genshi/src/chameleon/genshi/loader.py	2008-11-13 18:23:15 UTC (rev 92912)
+++ Sandbox/malthe/chameleon.genshi/src/chameleon/genshi/loader.py	2008-11-13 18:52:23 UTC (rev 92913)
@@ -6,7 +6,13 @@
 class TemplateLoader(BaseLoader):
     default_parser = language.Parser()
 
-    def load(self, filename):
-        return super(TemplateLoader, self).load(filename,
-                template.GenshiTemplateFile)
+    formats = { "xml"  : template.GenshiTemplateFile,
+                "text" : template.GenshiTextTemplateFile,
+               }
 
+    def load(self, filename, format="xml"):
+        """Load and return a template file. The format parameter determines
+        will parse the file. Valid options are `xml` and `text`."""
+        return super(TemplateLoader, self).load(filename, self.formats[format])
+
+



More information about the Checkins mailing list