A Python templating library
Project description
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 choc-expr
Functionnalities
- If-Then-Else statements
- 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...)
- Optional parenthesis in loop statement
Examples
from choc_expr import Expr as ChocExpr
age = 24 # or 15
print(ChocExpr("Kevin is @{age}>=18:an adult:a child; of {age} years old", vars()))
output :
>> Kevin is an adult of 24 years old
or
>> Kevin is a child of 15 years old
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.3.5.tar.gz
(5.6 kB
view details)
Built Distribution
File details
Details for the file choc_expr-1.3.5.tar.gz
.
File metadata
- Download URL: choc_expr-1.3.5.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95d45b9853a65596b0c9780072b91d3c66730b072c6b404bcb6238a8bf92afd4 |
|
MD5 | 84c1107923b65d526e3303dc7fdb93aa |
|
BLAKE2b-256 | 3a99501776892dbc1c19da8be813adb1fd85d3c5cea8c5789b35b94bc776556f |
File details
Details for the file choc_expr-1.3.5-py3-none-any.whl
.
File metadata
- Download URL: choc_expr-1.3.5-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f136b7b79f42431eab2aab69dfcee8bdbbb5c14e36aa334ab97307d4f83cb91 |
|
MD5 | 557b9573914d6f5f840057623fdee8a4 |
|
BLAKE2b-256 | 9b0e1a13b5a3e06be32d705fd0dc3fcf186a929687b6d31ddeb24cf8a3f96ccd |