Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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
```