diff options
author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2011-12-18 20:01:53 -0800 |
---|---|---|
committer | Chris Jerdonek <chris.jerdonek@gmail.com> | 2011-12-18 20:01:53 -0800 |
commit | cc18da306f6a583b68c15bb896a875a403de876f (patch) | |
tree | c7a425e1a44ebb909ab417a13ebc9a745ce044a2 /pystache/loader.py | |
parent | 9b087b282ce0d3061e81d12eb16b6c73ac09afea (diff) | |
download | pystache-cc18da306f6a583b68c15bb896a875a403de876f.tar.gz |
Fixed issue #40.
Diffstat (limited to 'pystache/loader.py')
-rw-r--r-- | pystache/loader.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/pystache/loader.py b/pystache/loader.py index 9e59774..83690d2 100644 --- a/pystache/loader.py +++ b/pystache/loader.py @@ -22,6 +22,9 @@ class Loader(object): search_dirs: the directories in which to search for templates. Defaults to the current working directory. + extension: the template file extension. Defaults to "mustache". + Pass False for no extension. + """ if extension is None: extension = DEFAULT_EXTENSION @@ -35,6 +38,13 @@ class Loader(object): self.template_encoding = encoding self.template_extension = extension + def make_file_name(self, template_name): + file_name = template_name + if self.template_extension is not False: + file_name += os.path.extsep + self.template_extension + + return file_name + def load_template(self, template_name): """ Find and load the given template, and return it as a string. @@ -43,7 +53,8 @@ class Loader(object): """ search_dirs = self.search_dirs - file_name = template_name + '.' + self.template_extension + + file_name = self.make_file_name(template_name) for dir_path in search_dirs: file_path = os.path.join(dir_path, file_name) |