Index: packager.py |
=================================================================== |
--- a/packager.py |
+++ b/packager.py |
@@ -113,6 +113,25 @@ |
else: |
print >>sys.stderr, 'Warning: Mapped file %s doesn\'t exist' % source |
+ def preprocess(self, filenames, params={}): |
+ import jinja2 |
+ |
+ env = jinja2.Environment( |
+ # TODO: Make the first run page generated on all platforms and get |
+ # rid of the HTML comment syntax, wrapped around the jinja syntax. |
+ block_start_string='<!-- {%', |
+ block_end_string='%} -->', |
+ variable_start_string='<!-- {{', |
+ variable_end_string='}} -->', |
+ comment_start_string='<-- {#', |
+ comment_end_string='#} -->' |
+ ) |
+ |
+ for filename in filenames: |
+ env.autoescape = os.path.splitext(filename) in ('.html', '.xml') |
+ template = env.from_string(self[filename].decode('utf-8')) |
+ self[filename] = template.render(params).encode('utf-8') |
+ |
def zip(self, outFile, sortKey=None): |
zip = zipfile.ZipFile(outFile, 'w', zipfile.ZIP_DEFLATED) |
names = self.keys() |