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

- First commit, works but very sparse.

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