Revert "Add yaml_safe filter"

This reverts commit 2405ff11b5.

This never worked:

* yaml_txt is stripped and never ends with a '\n'
* len(string - 5) doesn't work
* yaml.safe_dump() doesn't allow to set a custom Dumper() (see
  10c55a6244/lib/yaml/__init__.py (__init__.py-212) )

Also, #36611 for related bug and fix.
This commit is contained in:
Jonathan Ballet 2017-01-04 12:10:21 +01:00
parent ec60f9c721
commit f7712d417f

View file

@ -349,7 +349,6 @@ class SerializerExtension(Extension, object):
super(SerializerExtension, self).__init__(environment)
self.environment.filters.update({
'yaml': self.format_yaml,
'yaml_safe': self.format_yaml_safe,
'json': self.format_json,
'python': self.format_python,
'load_yaml': self.load_yaml,
@ -391,13 +390,6 @@ class SerializerExtension(Extension, object):
yaml_txt = yaml_txt[:len(yaml_txt)-4]
return Markup(yaml_txt)
def format_yaml_safe(self, value, flow_style=True):
yaml_txt = yaml.safe_dump(value, default_flow_style=flow_style,
Dumper=OrderedDictDumper).strip()
if yaml_txt.endswith('\n...\n'):
yaml_txt = yaml_txt[:len(yaml_txt-5)]
return Markup(yaml_txt)
def format_python(self, value):
return Markup(pprint.pformat(value).strip())