Example #1
0
    def _write_files(self):
        """Write all files for the blog to _site

        Convert all templates to straight HTML
        Copy other non-template files directly"""

        for src, dest in _walk_files(self.output_dir, False):
            if not os.path.exists(os.path.dirname(dest)):
                util.mkdir(os.path.dirname(dest))

            if src.endswith(".mako"):
                with open(src, encoding='utf-8') as t_file:
                    template = Template(t_file.read(),
                                        lookup=self.template_lookup,
                                        uri=src,
                                        output_encoding=None,
                                        strict_undefined=True)
                    template.zf_meta = {"path": src}

                with self._output_file(dest) as html_file:
                    html = self.template_render(template)
                    html_file.write(html)
            else:
                self.copyfile(src, dest)