Pablo Caro Revuelta committed 2751f6d

Support of .html.mako extension

Comments (0)

Files changed (1)


         if fnmatch.fnmatch(source_filepath, "*.html"):
-            f =, "r", "utf8")
-            data =
-            f.close()
-            t = Template(data, lookup=template_lookup, uri=source_filepath)
-            f =, "w", "utf8")
-            f.write(t.render_unicode(
-                root_path=RootPath(os.path.relpath(root_path, os.path.dirname(source_filepath))),
-                current_page=source_filepath,
-                g=type("Global", (object,), {})
-            ))
-            f.close()
+            render_and_copy(source_filepath, dest_filepath, template_lookup, root_path)
+        elif fnmatch.fnmatch(source_filepath, "*.mako"):
+            render_and_copy(source_filepath, dest_filepath[:-len('.mako')],
+                            template_lookup, root_path)
             shutil.copy(source_filepath, dest_filepath)
+def render_and_copy(source, dest, lookup, root_path):
+    f =, "r", "utf8")
+    data =
+    f.close()
+    t = Template(data, lookup=lookup, uri=source)
+    f =, "w", "utf8")
+    f.write(t.render_unicode(
+        root_path=RootPath(os.path.relpath(root_path, os.path.dirname(source))),
+        current_page=source,
+        g=type("Global", (object,), {})
+    ))
+    f.close()
 def main():
     parser = argparse.ArgumentParser(
         description="""A tool to generate a static web site, with Mako templates."""
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.