Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix #2531 — pass post and lang to compilers
  • Loading branch information
Kwpolska committed Oct 14, 2016
1 parent 660f7fa commit 74fa2f4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
11 changes: 11 additions & 0 deletions CHANGES.txt
@@ -1,3 +1,14 @@
New in master
=============

Bugfixes
--------

Features
--------

* Pass ``post`` object and ``lang`` to post compilers (Issue #2531)

New in v7.8.1
=============

Expand Down
10 changes: 9 additions & 1 deletion nikola/plugin_categories.py
Expand Up @@ -275,8 +275,16 @@ def register_extra_dependencies(self, post):
"""Add dependency to post object to check .dep file."""
post.add_dependency(lambda: self._read_extra_deps(post), 'fragment')

def compile(self, source, dest, is_two_file=False, post=None, lang=None):
"""Compile the source file and save it to dest."""
# For backwards compatibility, call `compile_html`
# If you are implementing a compiler, please implement `compile` and
# ignore `compile_html`
self.compile_html(source, dest, is_two_file)

# TODO remove in v8
def compile_html(self, source, dest, is_two_file=False):
"""Compile the source, save it on dest."""
"""Compile the source, save it on dest. (DEPRECATED)"""
raise NotImplementedError()

def create_post(self, path, content=None, onefile=False, is_page=False, **kw):
Expand Down
6 changes: 4 additions & 2 deletions nikola/post.py
Expand Up @@ -97,7 +97,9 @@ def __init__(
"""
self.config = config
self.compiler = compiler
self.compile_html = self.compiler.compile_html
self.compile = self.compiler.compile
# TODO remove in v8
self.compile_html = self.compile
self.demote_headers = self.compiler.demote_headers and self.config['DEMOTE_HEADERS']
tzinfo = self.config['__tzinfo__']
if self.config['FUTURE_IS_NOW']:
Expand Down Expand Up @@ -516,7 +518,7 @@ def wrap_encrypt(path, password):
return
# Set the language to the right thing
LocaleBorg().set_locale(lang)
self.compile_html(
self.compile(
self.translated_source_path(lang),
dest,
self.is_two_file)
Expand Down

0 comments on commit 74fa2f4

Please sign in to comment.