summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lesana/templating.py7
-rw-r--r--tests/test_templating.py2
2 files changed, 7 insertions, 2 deletions
diff --git a/lesana/templating.py b/lesana/templating.py
index 8ff9fcb..95c6146 100644
--- a/lesana/templating.py
+++ b/lesana/templating.py
@@ -28,8 +28,11 @@ def to_yaml(data):
data = ruamel.yaml.scalarstring.LiteralScalarString(data + "\n")
elif isinstance(data, decimal.Decimal):
data = str(data)
+ elif data is None:
+ return 'null'
yaml = ruamel.yaml.YAML()
s_io = io.StringIO()
- yaml.dump(data, s_io)
- res = s_io.getvalue().strip('...\n').strip()
+ yaml.dump({'data': data}, s_io)
+ res = s_io.getvalue()
+ res = res.lstrip('{data:').lstrip().strip()
return res
diff --git a/tests/test_templating.py b/tests/test_templating.py
index aadcf66..57d7f7a 100644
--- a/tests/test_templating.py
+++ b/tests/test_templating.py
@@ -52,6 +52,8 @@ class testFilters(unittest.TestCase):
res = templating.to_yaml(s)
self.assertTrue(res.startswith("|\n"))
self.assertNotIn('\n', res.lstrip("|\n"))
+ for line in res.lstrip("|\n").split('\n'):
+ self.assertTrue(line.startswith(" "))
if __name__ == '__main__':