Jinja2 Style Guide
Preserve shared macros and the repository’s Jinja environment. Render with the same extensions and context as the real generator.
- Keep presentation logic in templates and normalization in shared configuration or helpers. Pass context explicitly to imports when needed.
- Use whitespace controls intentionally; preserve YAML indentation, Makefile tabs and Markdown fences.
- Serialize strings appropriately for JSON, YAML, TOML, shell and Python rather than interpolating unescaped values.
- Preserve nested Cookiecutter and Jekyll expressions using raw blocks when needed. Do not evaluate downstream template markers.
- Treat missing required values as errors. Use defaults only for documented optional inputs, preserving false and empty values.
```jinja2 {% for name in names %}
- {{ name | tojson }} {% endfor %}```
Run Jinja syntax checks and bake real contexts, including quoted text, optional features and nested templates. Validate output with its own parser.