Mercurial > p > roundup > code
comparison roundup/cgi/templating.py @ 4748:e339583eae8e
templating: rename precompileTemplates to precompile
| author | anatoly techtonik <techtonik@gmail.com> |
|---|---|
| date | Mon, 21 Jan 2013 23:51:39 +0300 |
| parents | 955860a18e12 |
| children | 0421390b3094 |
comparison
equal
deleted
inserted
replaced
| 4747:955860a18e12 | 4748:e339583eae8e |
|---|---|
| 82 """ Base for engine-specific template Loader class.""" | 82 """ Base for engine-specific template Loader class.""" |
| 83 def __init__(self, dir): | 83 def __init__(self, dir): |
| 84 # loaders are given the template directory as a first argument | 84 # loaders are given the template directory as a first argument |
| 85 pass | 85 pass |
| 86 | 86 |
| 87 def precompileTemplates(self): | 87 def precompile(self): |
| 88 """ Go through a directory and precompile all the templates therein | 88 """ This method may be called when tracker is loaded to precompile |
| 89 """ | 89 templates that support this ability. |
| 90 """ | |
| 91 # [ ] move implementation out of API | |
| 90 for filename in os.listdir(self.dir): | 92 for filename in os.listdir(self.dir): |
| 91 # skip subdirs | 93 # skip subdirs |
| 92 if os.path.isdir(filename): | 94 if os.path.isdir(filename): |
| 93 continue | 95 continue |
| 94 | 96 |
| 118 """ | 120 """ |
| 119 raise NotImplementedError | 121 raise NotImplementedError |
| 120 | 122 |
| 121 def __getitem__(self, name): | 123 def __getitem__(self, name): |
| 122 """Special method to access templates by loader['name']""" | 124 """Special method to access templates by loader['name']""" |
| 125 # [ ] not sure if it is needed for anything except TAL templates | |
| 123 try: | 126 try: |
| 124 return self.load(name) | 127 return self.load(name) |
| 125 except NoTemplate, message: | 128 except NoTemplate, message: |
| 126 raise KeyError, message | 129 raise KeyError, message |
| 127 | 130 |
