Pre-render the blog posts with Jinja2 so that URLs etc. can be properly handled

This commit is contained in:
str4d
2013-01-16 01:52:31 +00:00
parent 8e09d84d09
commit ca8717e172
2 changed files with 7 additions and 3 deletions

View File

@ -25,7 +25,7 @@ we will have more information for you when we release 0.9.5.
Files are available on the `download page`_.
.. _`download page`: /download.html
.. _`download page`: {{ get_url('downloads_select') }}
**RELEASE DETAILS**

View File

@ -1,7 +1,7 @@
import codecs
import datetime
from docutils.core import publish_parts
from flask import abort, g, safe_join, url_for
from flask import abort, g, render_template_string, safe_join, url_for
import os
import os.path
@ -93,7 +93,11 @@ def render_blog_post(slug):
with codecs.open(path, encoding='utf-8') as fd:
content = fd.read()
return publish_parts(source=content, source_path=BLOG_DIR, writer_name="html")
# render the post with Jinja2 to handle URLs etc.
rendered_content = render_template_string(content)
# publish the post with docutils
return publish_parts(source=rendered_content, source_path=BLOG_DIR, writer_name="html")
def get_metadata_from_meta(meta):
metaLines = meta.split('\n')