A powerful recursive Markdown template engine
Project description
📝 PyAct Builder
PyAct Builder is a lightweight yet powerful Markdown template engine that allows you to dynamically generate documents using Python scripts.
Thanks to recursive processing, you can build complex documents from small, independent blocks ("nodes"), inject data (dates, API results, calculations), and automate the creation of reports or static pages.
🚀 Key Features
- Python Integration: Each text fragment can have a corresponding
.pyscript that supplies data. - Recursion: Nest templates within templates without limits (e.g.,
Main -> Section -> Component). - Simple Syntax: Use
{[component]}to insert blocks and{{variable}}to insert data. - CLI Tool: A built-in command-line tool for quick setup and building.
📦 Installation
Install the package directly from PyPI:
pip install pyact
⚡ Quick Start
-
Initialize a new project: The tool automatically generates the directory structure and example files.
pyact make -
Build the document: Processes
main.mdand saves the result in theoutput/folder.pyact run
📂 Project Structure
After running the make command, your project will look like this:
.
├── main.md # Main input file
├── output/ # Destination for the final file (output.md)
└── nodes/ # Folder containing your components
├── header.md # Component template
└── header.py # Component logic (optional)
📖 How It Works
The system relies on two types of tags:
1. Component Tags: {[name]}
These insert content from the nodes/name.md file. If a corresponding nodes/name.py file exists, it will be executed first to provide data to the template.
Example in main.md:
# Daily Report
Below are the sales figures.
{[sales_table]}
2. Variable Tags: {{key}}
Inside .md files located in the nodes/ folder, you can use variables that will be replaced by the Python script.
Example in nodes/sales_table.py:
def sales_table():
# Return a dictionary (dict) with data
return {
"date": "2023-10-27",
"total": 1500
}
Example in nodes/sales_table.md:
### Sales for {{date}}
Total revenue was: **{{total}} USD**.
Final Result (output.md):
# Daily Report
Below are the sales figures.
### Sales for 2023-10-27
Total revenue was: **1500 USD**.
🛠️ Advanced
Returning JSON
If your Python script is complex, instead of a dictionary (dict), it can return a JSON formatted string. The engine will parse it automatically.
Error Handling
If you forget to create an .md file or if a .py script returns an error, the builder will notify you in the console. In the final output file, it will simply skip the faulty fragment instead of breaking the entire document.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyact_engine-0.1.0.tar.gz.
File metadata
- Download URL: pyact_engine-0.1.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e558c1aa89a139ea58efa5de7e021eec906ab1495d95008a3f18d66a29e68063
|
|
| MD5 |
99e16f6bcfd1719093fff2429408393d
|
|
| BLAKE2b-256 |
ae8e9d5044d79719ee2c94a71b6c6a16950f9db275b5b341f1818c60747120a8
|
File details
Details for the file pyact_engine-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyact_engine-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dccf785ce9ed58e82515eaf9fba030caee2b246be7bea8291c127b23b0b89d0
|
|
| MD5 |
ee6ce4b47c634249a1e669595a88a137
|
|
| BLAKE2b-256 |
bf2591839c5900ce72f640762b0d5f1110f58aa3208f527d4fcfa8816f77fef8
|