A simple, dependency-free template and internationalization toolkit for iFlow skills. Provides template rendering with variable substitution, conditionals, and loops, plus multi-language support.
bash
# Clone or copy to your skills directory
openclaw skills install iflow-template-toolkit
python
from iflow_template_toolkit import TemplateEngine, render_template
# Quick render from string
result = render_template("Hello {{name}}!", {"name": "World"})
# Output: "Hello World!"
# Using TemplateEngine class
engine = TemplateEngine("./templates")
result = engine.render_file("config.md", {
"project_name": "my-project",
"team_size": 5
})
Variables:
text
Hello {{name}}!
Project: {{project_name}}
Conditionals:
text
{% if status == "active" %}
Status is active
{% elif status == "pending" %}
Status is pending
{% else %}
Status unknown
{% endif %}
Loops:
text
{% for item in items %}
- {{item}} ({{index1}})
{% endfor %}
python
from iflow_template_toolkit import Translator, t, init_translator
# Initialize with translations
init_translator({
'en': {'greeting': 'Hello', 'farewell': 'Goodbye'},
'zh': {'greeting': '你好', 'farewell': '再见'}
}, default_lang='en')
# Translate
t('greeting') # "Hello"
t('greeting', lang='zh') # "你好"
# With interpolation
t('welcome', name='John') # "Welcome, John!" (if translation is "Welcome, {name}!")
FeatureDescriptionVariable Substitution{{variable}} syntaxConditionals{% if %}...{% elif %}...{% else %}...{% endif %}Loops{% for item in items %}...{% endfor %}Comparison==, !=, in, not in operatorsLoop Variablesindex, index1, first, lastMulti-languageJSON-based translation filesFallbackFalls back to default language
text
iflow-template-toolkit/
├── src/
│ ├── __init__.py
│ ├── template_engine.py
│ ├── i18n/
│ │ ├── __init__.py
│ │ ├── translator.py
│ │ └── langs/
│ │ ├── en.json
│ │ └── zh.json
│ └── templates/
├── tests/
├── SKILL.md
└── README.md
1.0.0