Mercurial > p > roundup > code
diff roundup/cgi/templating.py @ 2959:fa5410ae581d
allow use of XML templates again
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 25 Nov 2004 22:19:51 +0000 |
| parents | 4511fd6c5dbf |
| children | 68ba01244341 |
line wrap: on
line diff
--- a/roundup/cgi/templating.py Thu Nov 25 22:17:04 2004 +0000 +++ b/roundup/cgi/templating.py Thu Nov 25 22:19:51 2004 +0000 @@ -83,11 +83,12 @@ if os.path.exists(src): return (src, filename) - # try with a .html extension (new-style) - filename = filename + '.html' - src = os.path.join(dir, filename) - if os.path.exists(src): - return (src, filename) + # try with a .html or .xml extension (new-style) + for extension in '.html', '.xml': + filename = filename + extension + src = os.path.join(dir, filename) + if os.path.exists(src): + return (src, filename) # no extension == no generic template is possible if not extension: @@ -119,14 +120,19 @@ ''' Go through a directory and precompile all the templates therein ''' for filename in os.listdir(self.dir): - # skip files without ".html" extension - .css, .js etc. - if not filename.endswith(".html"): - continue # skip subdirs if os.path.isdir(filename): continue + # skip files without ".html" or ".xml" extension - .css, .js etc. + for extension in '.html', '.xml': + if filename.endswith(extension): + break + else: + continue + # remove "html" extension - filename = filename[:-len(".html")] + filename = filename[:-len(extension)] + # load the template if '.' in filename: name, extension = filename.split('.', 1)
