aboutsummaryrefslogtreecommitdiffstats
path: root/nikola/plugins/compile/php.py
diff options
context:
space:
mode:
Diffstat (limited to 'nikola/plugins/compile/php.py')
-rw-r--r--nikola/plugins/compile/php.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/nikola/plugins/compile/php.py b/nikola/plugins/compile/php.py
index d2559fd..818e10d 100644
--- a/nikola/plugins/compile/php.py
+++ b/nikola/plugins/compile/php.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2016 Roberto Alsina and others.
+# Copyright © 2012-2020 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
@@ -24,16 +24,14 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-"""Implementation of compile_html for HTML+php."""
+"""Page compiler plugin for PHP."""
-from __future__ import unicode_literals
-
-import os
import io
+import os
+from hashlib import md5
from nikola.plugin_categories import PageCompiler
from nikola.utils import makedirs, write_metadata
-from hashlib import md5
class CompilePhp(PageCompiler):
@@ -42,8 +40,8 @@ class CompilePhp(PageCompiler):
name = "php"
friendly_name = "PHP"
- def compile_html(self, source, dest, is_two_file=True):
- """Compile source file into HTML and save as dest."""
+ def compile(self, source, dest, is_two_file=True, post=None, lang=None):
+ """Compile the source file into HTML and save as dest."""
makedirs(os.path.dirname(dest))
with io.open(dest, "w+", encoding="utf8") as out_file:
with open(source, "rb") as in_file:
@@ -51,6 +49,10 @@ class CompilePhp(PageCompiler):
out_file.write('<!-- __NIKOLA_PHP_TEMPLATE_INJECTION source:{0} checksum:{1}__ -->'.format(source, hash))
return True
+ def compile_string(self, data, source_path=None, is_two_file=True, post=None, lang=None):
+ """Compile PHP into HTML strings."""
+ return data, []
+
def create_post(self, path, **kw):
"""Create a new post."""
content = kw.pop('content', None)
@@ -76,9 +78,7 @@ class CompilePhp(PageCompiler):
content += '\n'
with io.open(path, "w+", encoding="utf8") as fd:
if onefile:
- fd.write('<!--\n')
- fd.write(write_metadata(metadata))
- fd.write('-->\n\n')
+ fd.write(write_metadata(metadata, comment_wrap=True, site=self.site, compiler=self))
fd.write(content)
def extension(self):