Skip to content

Commit

Permalink
Support using post.text() in post-list directive (Issue #1671) and, i…
Browse files Browse the repository at this point in the history
…n general, get post.text() for posts at any time.
  • Loading branch information
ralsina committed May 1, 2015
1 parent e66df3a commit a35ebf1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -18,6 +18,7 @@ Features
Bugfixes
--------

* Support using post.text() in post_list_directive.tmpl (Issue #1671)
* Avoid recursive dep when using post-list in a post (Issue #1671)
* Encode IDNs to Punycode in ``nikola init`` and in links;
show an error if the site URL is not Punycode (Issue #1644)
Expand Down
8 changes: 8 additions & 0 deletions nikola/post.py
Expand Up @@ -526,8 +526,16 @@ def text(self, lang=None, teaser_only=False, strip_html=False, show_read_more_li
if lang is None:
lang = nikola.utils.LocaleBorg().current_lang
file_name = self._translated_file_path(lang)

# Yes, we compile it and screw it.
# This may be controversial, but the user (or someone) is asking for the post text
# and the post should not just refuse to give it.
if not os.path.isfile(file_name):
self.compile(lang)

with io.open(file_name, "r", encoding="utf8") as post_file:
data = post_file.read().strip()

if self.compiler.extension() == '.php':
return data
try:
Expand Down

0 comments on commit a35ebf1

Please sign in to comment.