Skip to content
Snippets Groups Projects
Commit ecd1d102 authored by nimrod's avatar nimrod
Browse files

- First commit, works but very sparse.

parent 4bf67215
No related branches found
No related tags found
No related merge requests found
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: 97b88d9610bcc03982ddac33caba98bb2b751f5f
hooks:
- id: check-added-large-files
- id: check-json
- id: check-xml
- id: check-yaml
- id: check-merge-conflict
- repo: https://www.shore.co.il/git/shell-pre-commit/
sha: 604fe77b53d3514d5ad0f66764c7783850bb6e98
hooks:
- id: shell-lint
recursive-include eb-prune *.py recursive-include eb-prune *.py
exclude .pre-commit-config.yaml exclude .pre-commit-config.yaml
include README.rst include *.rst
include VERSION include VERSION
include *.txt
...@@ -3,6 +3,15 @@ Template ...@@ -3,6 +3,15 @@ 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.
Example
-------
.. code:: shell
$ export name='John'
$ echo 'Hello {{ name if name is defined else 'world' }}. | template
Hello John.
TODO TODO
---- ----
......
0.0.1 0.1.0
\ No newline at end of file
...@@ -4,8 +4,8 @@ from setuptools import setup, find_packages ...@@ -4,8 +4,8 @@ from setuptools import setup, find_packages
setup( setup(
name='template', name='template',
version=open('VERSION', 'r').read(), version=open('VERSION', 'r').read(),
description='A CLI tool for generating files from Jinja2 templates and description='''A CLI tool for generating files from Jinja2 templates and
environment variables.', environment variables.''',
long_description=open('README.rst', 'r').read(), long_description=open('README.rst', 'r').read(),
url='https://www.shore.co.il/git/template', url='https://www.shore.co.il/git/template',
author='Nimrod Adar', author='Nimrod Adar',
......
...@@ -3,19 +3,20 @@ ...@@ -3,19 +3,20 @@
from __future__ import (absolute_import, division, from __future__ import (absolute_import, division,
print_function, unicode_literals) print_function, unicode_literals)
from jinja2 import FileSystemLoader, DictLoader from jinja2 import Template
from jinja2.environment import Environment
from os import environ from os import environ
from sys import stdin, argv from sys import stdin
def render(template): def render(template):
env = Environment() t = Template(template)
return env.from_string(template).render(environ) return t.render(environ)
def usage(): def usage():
raise NotImplemented raise NotImplemented
def main(): def main():
template = stdin.read() template = stdin.read()
print(render(template)) print(render(template))
......
#!/bin/sh -e
test "$(echo '{{ name }}' | name='Nimrod' template)" = "Nimrod"
...@@ -13,6 +13,7 @@ commands = ...@@ -13,6 +13,7 @@ commands =
check-manifest --ignore tox.ini,tests* check-manifest --ignore tox.ini,tests*
python setup.py check -m -r -s python setup.py check -m -r -s
flake8 . flake8 .
./tests.sh
[testenv:release] [testenv:release]
basepython = python basepython = python
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment