diff --git a/README.md b/README.md index 7ec6d21..b2039c2 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,7 @@ Finally, the following additionals filters are avilable: **boolean(str)**: Convert the argument into a boolean. A case insensitive comparison to - "true", "yes", and "1" will return `True`. Everything else is false. + "true", "yes", "on", and "1" will return `True`. Everything else is false. **b64encode(str)**: Base 64 encode the value. diff --git a/j2tmpl/cli.py b/j2tmpl/cli.py index a1f88a4..bf0abff 100755 --- a/j2tmpl/cli.py +++ b/j2tmpl/cli.py @@ -91,7 +91,7 @@ def boolean_filter(value): if isinstance(value, Undefined): return value - return str(value).lower() in ['true', 'yes', '1'] + return str(value).lower() in ['true', 'yes', 'on', '1'] def b64encode_filter(value): diff --git a/setup.py b/setup.py index d8afbd2..87b7678 100644 --- a/setup.py +++ b/setup.py @@ -5,11 +5,11 @@ long_description = fh.read() install_requires = ["jinja2"] -tests_requires = ["pytest", "flake8", "pytest-cover", "pytest-flake8"] +tests_requires = ["pytest", "flake8<3.8.0", "pytest-cover", "pytest-flake8"] setup( name="j2tmpl", - version="0.0.12", + version="0.0.13", author="Ilya Kogan", author_email="kogan@ohio.edu", url="https://github.com/ikogan/j2tmpl", diff --git a/tests/conftest.py b/tests/conftest.py index e043825..4af0752 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -17,9 +17,11 @@ def common_environment(): 'TEST_BOOLEAN_TRUE': 'true', 'TEST_BOOLEAN_YES': 'yes', 'TEST_BOOLEAN_ONE': '1', + 'TEST_BOOLEAN_ON': 'on', 'TEST_BOOLEAN_FALSE': 'false', 'TEST_BOOLEAN_NO': 'no', 'TEST_BOOLEAN_ZERO': '0', + 'TEST_BOOLEAN_OFF': 'off', 'SHELL': '/bin/bash', 'SHLVL': '2', '_': 'whatisthis', @@ -50,4 +52,4 @@ def common_rendered(): CAMEL_CASE_VARIABLE=handlethistoo JAVA_camelCaseVariable=thisshouldbefun ITERATION_TEST_1_VALUE=first -ITERATION_TEST_2_VALUE=second""" \ No newline at end of file +ITERATION_TEST_2_VALUE=second""" diff --git a/tests/templates/filters/boolean.jinja b/tests/templates/filters/boolean.jinja index 7ed9cbd..aeb2443 100644 --- a/tests/templates/filters/boolean.jinja +++ b/tests/templates/filters/boolean.jinja @@ -8,6 +8,8 @@ {% if test.boolean.one|boolean %}cool{% else %}bad{% endif %} +{% if test.boolean.on|boolean %}cool{% else %}bad{% endif %} + {% if test.boolean.false|boolean %}bad{% else %}cool{% endif %} {% if test.boolean.false|upper|boolean %}bad{% else %}cool{% endif %} @@ -16,4 +18,6 @@ {% if test.boolean.zero|boolean %}bad{% else %}cool{% endif %} +{% if test.boolean.off|boolean %}bad{% else %}cool{% endif %} + {% if test.boolean.undefined|boolean %}bad{% else %}cool{% endif %}