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.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/nikola/plugins/compile/php.py b/nikola/plugins/compile/php.py
index 0a652a6..601f098 100644
--- a/nikola/plugins/compile/php.py
+++ b/nikola/plugins/compile/php.py
@@ -33,12 +33,7 @@ import shutil
import codecs
from nikola.plugin_categories import PageCompiler
-from nikola.utils import makedirs
-
-try:
- from collections import OrderedDict
-except ImportError:
- OrderedDict = dict # NOQA
+from nikola.utils import makedirs, write_metadata
class CompilePhp(PageCompiler):
@@ -50,18 +45,23 @@ class CompilePhp(PageCompiler):
makedirs(os.path.dirname(dest))
shutil.copyfile(source, dest)
- def create_post(self, path, onefile=False, is_page=False, **kw):
- metadata = OrderedDict()
+ def create_post(self, path, **kw):
+ content = kw.pop('content', None)
+ onefile = kw.pop('onefile', False)
+ # is_page is not used by create_post as of now.
+ kw.pop('is_page', False)
+ metadata = {}
metadata.update(self.default_metadata)
metadata.update(kw)
os.makedirs(os.path.dirname(path))
+ if not content.endswith('\n'):
+ content += '\n'
with codecs.open(path, "wb+", "utf8") as fd:
if onefile:
- fd.write('<!-- \n')
- for k, v in metadata.items():
- fd.write('.. {0}: {1}\n'.format(k, v))
+ fd.write('<!--\n')
+ fd.write(write_metadata(metadata))
fd.write('-->\n\n')
- fd.write("\n<p>Write your {0} here.</p>".format('page' if is_page else 'post'))
+ fd.write(content)
def extension(self):
return ".php"