|
| 1 | +--- |
| 2 | +title: Kida 0.4.0 |
| 3 | +description: list comprehensions, error boundaries, i18n trans blocks, scoped slots, and a two-phase partial evaluator |
| 4 | +date: 2026-04-10 |
| 5 | +draft: false |
| 6 | +lang: en |
| 7 | +tags: [release, changelog, expressions, i18n, error-handling, compiler, performance] |
| 8 | +keywords: [release, 0.4.0, list-comprehensions, error-boundaries, i18n, trans, scoped-slots, partial-evaluator, babel, extraction] |
| 9 | +--- |
| 10 | + |
| 11 | +# v0.4.0 |
| 12 | + |
| 13 | +**Released** 2026-04-10. |
| 14 | + |
| 15 | +Kida 0.4.0 is the biggest feature release since the project's inception — list comprehensions, |
| 16 | +error boundaries, i18n with Babel extraction, scoped slots, and a two-phase partial evaluator |
| 17 | +that widens the compile-time optimization surface. |
| 18 | + |
| 19 | +## Highlights |
| 20 | + |
| 21 | +- **List comprehensions** — `[x.name for x in users if x.active]` works natively in template expressions. |
| 22 | +- **Error boundaries** — `{% boundary %}` blocks catch render errors and fall back to safe defaults without aborting the whole page. |
| 23 | +- **i18n `{% trans %}` blocks** — Full internationalization support with pluralization, variable interpolation, and Babel-compatible message extraction. |
| 24 | +- **Scoped slots** — Components can expose data back to the caller via `{% slot name expose x, y %}`. |
| 25 | +- **Two-phase partial evaluator** — Constant folding, dead branch elimination, and loop unrolling at compile time for measurable render speedups. |
| 26 | + |
| 27 | +## Added |
| 28 | + |
| 29 | +### Expressions |
| 30 | + |
| 31 | +- **List comprehensions** — `[expr for var in iterable if condition]` with full parser, compiler, |
| 32 | + analysis (dependency tracking, purity), and CLI integration. (#62) |
| 33 | + |
| 34 | +### Template Control Flow |
| 35 | + |
| 36 | +- **Error boundaries** — `{% boundary %}...{% fallback %}...{% endboundary %}` catches exceptions |
| 37 | + during rendering and substitutes fallback content. Integrates with the environment's error handler. (#61) |
| 38 | +- **Scoped slots** — `{% slot name expose x, y %}` lets parent components bind slot-exposed variables, |
| 39 | + enabling inversion-of-control patterns. (#61) |
| 40 | + |
| 41 | +### Internationalization |
| 42 | + |
| 43 | +- **`{% trans %}` / `{% pluralize %}` blocks** — Mark translatable strings with variable interpolation |
| 44 | + and plural forms. The compiler generates `gettext`/`ngettext` calls. (#61) |
| 45 | +- **Babel extraction** — `kida.babel.extract` entry point lets `pybabel extract` pull translatable |
| 46 | + strings from Kida templates. (#63) |
| 47 | +- **`kida i18n` CLI** — `kida i18n extract` and `kida i18n analyze` commands for standalone message |
| 48 | + extraction and translation coverage analysis. (#63) |
| 49 | +- **Analysis integration** — i18n analysis module tracks translatable strings, detects missing |
| 50 | + translations, and integrates with the dependency and purity analyzers. (#63) |
| 51 | + |
| 52 | +### Compiler |
| 53 | + |
| 54 | +- **Partial evaluator phase 1** — Constant folding, filter inlining for pure built-in filters, |
| 55 | + dead branch elimination, and loop unrolling for small static iterables. Configurable via |
| 56 | + `Environment(partial_eval=True)` with per-strategy controls. (#64) |
| 57 | +- **Partial evaluator phase 2** — Extends optimization to conditional expressions, nested structures, |
| 58 | + string operations, comprehension folding, and cross-block constant propagation. (#65) |
| 59 | +- **`kida compile --optimize` CLI** — Inspect the optimized AST and see before/after comparisons. (#64, #65) |
| 60 | + |
| 61 | +## Changed |
| 62 | + |
| 63 | +- **Performance docs** — Updated to cover partial evaluation strategies and benchmarks. (#64) |
| 64 | +- **Compiler docs** — New sections on the optimization pipeline and custom filter purity. (#64) |
| 65 | +- **Configuration docs** — Documents `partial_eval` and related environment options. (#64) |
| 66 | + |
| 67 | +## Upgrade Notes |
| 68 | + |
| 69 | +1. No breaking changes. Drop-in upgrade from 0.3.4. |
| 70 | +2. Partial evaluation is opt-in — enable with `Environment(partial_eval=True)`. |
| 71 | +3. i18n requires no new dependencies; Babel integration is optional. |
| 72 | +4. GitHub Action version tag updated to `@v0.4.0`. |
| 73 | + |
| 74 | +## Links |
| 75 | + |
| 76 | +- [PyPI](https://pypi.org/project/kida-templates/) |
| 77 | +- [GitHub](https://github.com/lbliii/kida) |
| 78 | +- [Full Changelog](https://github.com/lbliii/kida/blob/main/CHANGELOG.md) |
0 commit comments