Skip to main content

A Python templating library

Project description

PyPI version Licence badge Python version Actions Status Dependencies Downloads per month Last commit

choc-expr

A Python templating library

Why ChocExpr ?

ChocExpr is used by Chocolatine to help to generate SQL queries, but you are free to use it for your own projects.

Installation

pip install chocexpr

Functionnalities

  • If-Then-Else statements (If test only with boolean actually)
  • Line break
  • Compact/Extended mode
  • Attributes evaluation :
    • Loop : unpack iterable and join it by a character separator
    • Attribute chain : follow the chain and return the nested value

TODO

  • Nested Conditions
  • Methods (upper, lower, title, etc...)
  • If condition resolution with an equality
  • Optional parenthesis in loop statement

Examples

from choc_expr import Expr as ChocExpr

condition = True  # or False
value_if_true = 1
value_if_false = 2
names = ("Kevin", "Sophia")
print(ChocExpr("@{condition}:{value_if_true} child is:{value_if_false} children (named $({names})) are;~playing football outside", vars()))

output :

>> 2 children (Kevin, Sophia) are
>> playing football outside

or

>> 1 child is
>> playing football outside

depending if condition is True or False.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

choc_expr-1.0.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

choc_expr-1.0-py3-none-any.whl (5.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page