Loading README.rst +12 −8 Original line number Diff line number Diff line Template ######## A CLI tool for generating files from Jinja2 templates and environment variables. A CLI tool for generating files from Jinja2 templates and environment variables. Examples -------- Loading @@ -11,6 +12,9 @@ Examples $ template -h usage: template [-h] [-o OUTPUT] [filename] A CLI tool for generating files from Jinja2 templates and environment variables. positional arguments: filename Input filename Loading @@ -23,7 +27,7 @@ Examples Hello John. $ echo '{{ USER }}' > username.j2 $ template --output username.txt username.j2 $ cat username $ cat username.txt John Loading @@ -32,12 +36,12 @@ Jinja filters The following Jinja filters were added: - to_yaml: Convert to yaml. - from_yaml: Convert from yaml. - to_json: Convert to json. - from_json: Convert from json. - pprint: Pretty print variable. - combine: Combine 2 dictionaries. - :code:`to_yaml`: Convert to yaml. - :code:`from_yaml`: Convert from yaml. - :code:`to_json`: Convert to json. - :code:`from_json`: Convert from json. - :code:`pprint`: Pretty print variable. - :code:`combine`: Combine 2 dictionaries. Example usage can be seen in :code:`tests.sh`. Loading template/__init__.py +3 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,9 @@ def render(template_string): def main(): parser = ArgumentParser() parser = ArgumentParser( description='''A CLI tool for generating files from Jinja2 templates and environment variables.''') parser.add_argument('filename', help='Input filename', type=argparse.FileType('r'), Loading template/filters.py +3 −3 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ def pprint(value): return pformat(value) def combine(lefthand, righthand): combined = lefthand.copy() combined.update(righthand) def combine(default, override): combined = default.copy() combined.update(override) return combined tests.sh +2 −0 Original line number Diff line number Diff line Loading @@ -36,5 +36,7 @@ echo '{{ [1, ] + [2, ] }}' > "$infile" test "$(template $infile)" = "[1, 2]" echo Testing combining dictionaries. echo '{{ {"a": 1, "b": 2}|combine({"a": 11, "c": 33}) }}' > "$infile" test "$(template $infile)" = "{'a': 11, 'c': 33, 'b': 2}" rm "$infile" "$outfile" Loading
README.rst +12 −8 Original line number Diff line number Diff line Template ######## A CLI tool for generating files from Jinja2 templates and environment variables. A CLI tool for generating files from Jinja2 templates and environment variables. Examples -------- Loading @@ -11,6 +12,9 @@ Examples $ template -h usage: template [-h] [-o OUTPUT] [filename] A CLI tool for generating files from Jinja2 templates and environment variables. positional arguments: filename Input filename Loading @@ -23,7 +27,7 @@ Examples Hello John. $ echo '{{ USER }}' > username.j2 $ template --output username.txt username.j2 $ cat username $ cat username.txt John Loading @@ -32,12 +36,12 @@ Jinja filters The following Jinja filters were added: - to_yaml: Convert to yaml. - from_yaml: Convert from yaml. - to_json: Convert to json. - from_json: Convert from json. - pprint: Pretty print variable. - combine: Combine 2 dictionaries. - :code:`to_yaml`: Convert to yaml. - :code:`from_yaml`: Convert from yaml. - :code:`to_json`: Convert to json. - :code:`from_json`: Convert from json. - :code:`pprint`: Pretty print variable. - :code:`combine`: Combine 2 dictionaries. Example usage can be seen in :code:`tests.sh`. Loading
template/__init__.py +3 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,9 @@ def render(template_string): def main(): parser = ArgumentParser() parser = ArgumentParser( description='''A CLI tool for generating files from Jinja2 templates and environment variables.''') parser.add_argument('filename', help='Input filename', type=argparse.FileType('r'), Loading
template/filters.py +3 −3 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ def pprint(value): return pformat(value) def combine(lefthand, righthand): combined = lefthand.copy() combined.update(righthand) def combine(default, override): combined = default.copy() combined.update(override) return combined
tests.sh +2 −0 Original line number Diff line number Diff line Loading @@ -36,5 +36,7 @@ echo '{{ [1, ] + [2, ] }}' > "$infile" test "$(template $infile)" = "[1, 2]" echo Testing combining dictionaries. echo '{{ {"a": 1, "b": 2}|combine({"a": 11, "c": 33}) }}' > "$infile" test "$(template $infile)" = "{'a': 11, 'c': 33, 'b': 2}" rm "$infile" "$outfile"