def render_posts(self):
"""Render posts using jinja2 templates."""
for post in tqdm(self.posts, unit=' pages', miniters=1, desc="Posts"):
template_name = "%s.html" % post.meta.template
template = self.jinja2.get_template(template_name)
html = post.html.decode("utf-8", 'ignore')
rv = template.render(content=html, meta=post.meta, posts=self.posts, plugin_data=self.plugin_data, config=self.config,
categories=self.posts_by_category.get_as_dict(), tags=self.posts_by_tag.get_as_dict(), templates=self.posts_by_template.get_as_dict(),
microdata=self.posts_by_microdata.get_as_dict())
# Liniting
linter_results = self.linter.lint(post, rv, self)
# Are we stopping on linting errors?
if linter_results.has_errors and self.config.linter.stop_on_error:
print post.filename
for error in linter_results.info:
print "\t-%s:%s" % (error[0], error[1])
sys.exit(-1)
path = "%s%s/" % (self.get_output_dir(), post.meta.permanent_url)
path = path.replace('//', '/')
files.write_file(path, 'index.html', rv)
### Templates functions ###
评论列表
文章目录