Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/comonadd/stemplates
Render file templates with embedded python code
https://github.com/comonadd/stemplates
Last synced: 9 days ago
JSON representation
Render file templates with embedded python code
- Host: GitHub
- URL: https://github.com/comonadd/stemplates
- Owner: comonadd
- License: mit
- Created: 2021-09-24T16:01:53.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2021-09-24T21:16:08.000Z (about 3 years ago)
- Last Synced: 2024-10-11T22:13:26.000Z (about 1 month ago)
- Language: C++
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# stemplates
Render files with embedded python code. Executes `exec` and substitutes
expression with the result.## Usage
```python
from stemplates import render_template
# Simple substitution
text = "Hello, {% username %}"
rendered = render_template(text, username="John")
# Conditionals
text = "Hello, {% f'{name} {lastname}' if full_name else name %}"
rendered = render_template(text, name="John", lastname="Green", full_name=False)
# Render files
render_file_to("some.template", "out.txt", param1="Param", param2="...")
```## Install
```bash
pip install stemplates
```