Explorar el Código

Merge pull request #1168 from detiber/padded_yaml_fix

Fix for to_padded_yaml filter
Brenton Leanhardt hace 9 años
padre
commit
920fdaab00
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  1. 3 0
      filter_plugins/oo_filters.py

+ 3 - 0
filter_plugins/oo_filters.py

@@ -479,6 +479,9 @@ class FilterModule(object):
     @staticmethod
     def to_padded_yaml(data, level=0, indent=2, **kw):
         ''' returns a yaml snippet padded to match the indent level you specify '''
+        if data in [None, ""]:
+            return ""
+
         try:
             transformed = yaml.safe_dump(data, indent=indent, allow_unicode=True, default_flow_style=False, **kw)
             padded = "\n".join([" " * level * indent + line for line in transformed.splitlines()])