def render_post(in_path, out_path): """ Renders a post from markdown to a Jinja template, then renders that template. """ # read file contents and decode to unicode post = posts.Post.from_file(in_path) # process markdown simple_html = post.process_markdown() html = process_html_for_post(simple_html, {'post': post}) # print(meta) posts.makedirs(out_path) with open(out_path, 'w') as out_f: out_f.write(html.encode('utf-8'))
def build_tags_pages(): tags_dict = generate_tags_mapping() # Create a page for each tag. for tag, posts in tags_dict.items(): page_url = PostMetadata.urlify_tag(tag) + '.html' page_url = 'posts/tags/' + page_url html = render_template( './static/_templates', 'post-tag-feed.jinja', {'posts': posts, 'tag_name': tag, 'page_url': '/' + page_url}) makedirs(page_url) with open(page_url, 'w') as page_file: page_file.write(html.encode('utf-8')) return tags_dict