Transform structured data (JSON/YAML/XML) into code, configs, and docs with Jinja2 templates
Project description
🔨 Template Forge
Stop writing boilerplate. Start building features.
Transform your structured data (JSON, YAML, XML, ARXML) into any text-based output—code, configs, docs, infrastructure—with the power of Jinja2 templates and intelligent data extraction.
🚀 Quick Start
# Install
pip install template-forge
# Generate from your data
template-forge config.yaml
# That's it! 🎉
📖 Getting Started Guide | 📚 Full Documentation | 💡 Examples
⚡ Why Template Forge?
The Problem
- 📝 Writing the same boilerplate code across services
- 🔄 Keeping configurations synchronized across environments
- 📚 Maintaining documentation that matches your code
- 😱 Losing custom code when regenerating files
The Solution
Template Forge uses your existing data to generate everything:
Your Data (JSON/YAML/XML) + Your Templates → Generated Everything
One command. Zero repetition. Complete control.
✨ 30-Second Demo
1. Your data (app.json):
{
"service": {
"name": "UserAPI",
"port": 8080,
"endpoints": ["users", "auth", "profile"]
}
}
2. Your template (service.py.j2):
# Generated {{ service.name }} Service
from flask import Flask
app = Flask("{{ service.name }}")
{% for endpoint in service.endpoints %}
@app.route("/{{ endpoint }}")
def {{ endpoint }}():
return {"endpoint": "{{ endpoint }}"}
{% endfor %}
if __name__ == "__main__":
app.run(port={{ service.port }})
3. Your config (config.yaml):
inputs:
- path: "app.json"
namespace: "service"
templates:
- template: "service.py.j2"
output: "service.py"
4. Generate:
template-forge config.yaml
5. Result (service.py):
# Generated UserAPI Service
from flask import Flask
app = Flask("UserAPI")
@app.route("/users")
def users():
return {"endpoint": "users"}
@app.route("/auth")
def auth():
return {"endpoint": "auth"}
@app.route("/profile")
def profile():
return {"endpoint": "profile"}
if __name__ == "__main__":
app.run(port=8080)
That's the power of Template Forge. 🚀
🎯 Key Features
📊 Universal Data Support
- JSON, YAML, XML, ARXML - Parse any structured format
- Multiple sources - Combine data from different files
- Namespacing - Avoid token collisions with hierarchical organization
- Smart extraction - Dot notation, array operations, wildcards
🎨 Powerful Templates
- Full Jinja2 - Complete template language support
- Custom filters -
snake_case,pascal_case,flatten,unique, more - Conditional generation - Only create files when conditions are met
- Foreach iteration - Generate multiple files from arrays
- Matrix generation - Cross-product combinations (platforms × configs)
🛡️ Code Preservation
- Keep custom code - Mark sections to preserve across regenerations
- Safe regeneration - Never lose your manual changes
- Smart merging - Automatically merge template updates with custom code
⚙️ Advanced Automation
- Pre/post hooks - Run commands before/after generation
- Conditional hooks - Execute based on data values
- Template inheritance - Reuse common template sections
- File watching - Auto-regenerate on data changes (coming soon)
📦 Installation
# From PyPI (recommended)
pip install template-forge
# With development tools
pip install template-forge[dev]
# From source
git clone https://github.com/CarloFornari/template-forge.git
cd template-forge
pip install -e .
Requirements: Python 3.8+
🎓 Learn More
- Getting Started Guide - From zero to expert
- User Guide - Complete feature reference
- Examples - Real-world use cases
- Basic Usage - Simple config and template
- Advanced Features - All capabilities
- AUTOSAR - Automotive XML processing
- Docker - Container configuration
- C++ Projects - Code generation
- Python Classes - Dynamic class creation
- YAML Configs - Configuration management
- API Reference - Detailed API documentation
- Configuration Guide - All config options
💡 Common Use Cases
🏗️ Multi-Environment Configurations
Generate environment-specific configs from a single data source:
# dev.yaml, staging.yaml, prod.yaml from one template
🔧 Microservices Boilerplate
Create consistent service structures across your architecture:
# API endpoints, Docker configs, K8s manifests, docs
📝 Documentation Generation
Keep docs in sync with your code/data:
# API docs, config references, user guides
🚗 Automotive (AUTOSAR)
Transform ARXML into C headers, configs, and documentation:
# ECU configs, CAN message definitions, system docs
🎨 Code Generation
Generate type-safe code from data models:
# Classes, interfaces, DTOs, validators
🤝 Contributing
Contributions are welcome! See CONTRIBUTING.md for guidelines.
Development Setup:
git clone https://github.com/CarloFornari/template-forge.git
cd template-forge
pip install -e ".[dev]"
pytest
📄 License
MIT License - see LICENSE for details.
🙏 Acknowledgments
Built with:
📞 Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: carlo.fornari@example.com
⭐ Star us on GitHub if Template Forge saves you time!
Made with ❤️ by Carlo Fornari
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 template_forge-1.0.0.tar.gz.
File metadata
- Download URL: template_forge-1.0.0.tar.gz
- Upload date:
- Size: 226.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
612b176bbf024eb724937cdc19cc7427ed9c4a1210aef962fc3665623fa18cf5
|
|
| MD5 |
161630d32de415c5dd619e65d7d2c5af
|
|
| BLAKE2b-256 |
a786c4e4239ec6322703a0ad6a62796c4c56a751b47b1451fca249f22c8e2167
|
File details
Details for the file template_forge-1.0.0-py3-none-any.whl.
File metadata
- Download URL: template_forge-1.0.0-py3-none-any.whl
- Upload date:
- Size: 38.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e2529a3345506ada5d81363e93374fe08c29d984c52b4b982cb356adc89e768
|
|
| MD5 |
1b7e54aaed1847e23304debc66dfa291
|
|
| BLAKE2b-256 |
84287b8faabedbcaec048583f690abfa3a51a68280bfb3bbf4061ede32f853fc
|