Skip to content

Commit

Permalink
Merge pull request #5 from Avielyo10/dump
Browse files Browse the repository at this point in the history
Fix data type error
  • Loading branch information
Avielyo10 committed Mar 6, 2024
2 parents 7d41656 + cc058ce commit dafb037
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions examples/data/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
}
]
},
"message": "jinja"
}
"message": "jinja",
"some_date": "2022-02-02"
}
3 changes: 2 additions & 1 deletion examples/data/data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ access_lists:
- action: permit
src: 10.0.0.0/22
dst: 10.100.0.0/24
message: jinja
message: jinja
some_date: 2022-02-02
1 change: 1 addition & 0 deletions examples/templates/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ ip access-list extended {{ acl }}
{% endfor %}(6)
{% endfor %}(7)
hello {{ message }}!
the date is {{ some_date }}
# All ACLs have been generated
6 changes: 3 additions & 3 deletions jinja2_tools/objects.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Data objects
"""
import json
import yaml
import sys

from colors import red
Expand Down Expand Up @@ -40,7 +40,7 @@ def get_extra_vars(self):
"""
A simple getter with verbose option
"""
print_verbose({'title': '[ExtraVars]', 'content': json.dumps(
print_verbose({'title': '[ExtraVars]', 'content': yaml.dump(
self.data, indent=2), 'verbose': self.verbose})
return self.data

Expand All @@ -66,7 +66,7 @@ def get_data(self):
sys.exit(128)
else:
self.data = load_yaml(ih_content)
print_verbose({'title': '[Data]', 'content': json.dumps(
print_verbose({'title': '[Data]', 'content': yaml.dump(
self.data, indent=2), 'verbose': self.verbose})
return self.data

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="jinja2-tools",
version="1.0.7",
version="1.0.8",
author="Aviel Yosef",
author_email="Avielyo10@gmail.com",
description="Use Jinja2 templates via cli",
Expand Down
2 changes: 2 additions & 0 deletions tests/test_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
(5)(6)
(7)
hello jinja!
the date is 2022-02-02
# All ACLs have been generated
"""

Expand All @@ -39,6 +40,7 @@
(6)
(7)
hello jinja!
the date is 2022-02-02
# All ACLs have been generated
"""

Expand Down

0 comments on commit dafb037

Please sign in to comment.