Last active
April 20, 2019 20:00
-
-
Save jbek7/5934478c89eacd95cf4499876147e817 to your computer and use it in GitHub Desktop.
Custom Jinja filter for nice order preserved YAML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import oyaml as yaml | |
import os | |
class FilterModule(object): | |
def filters(self): | |
return { | |
'to_yaml_preserve_order': self.to_yaml_preserve_order | |
} | |
def to_yaml_preserve_order(self, file_path): | |
data = yaml.load(open(os.path.abspath(file_path))) | |
yaml_dump = yaml.dump(data) | |
return yaml_dump | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment