diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-29 03:56:32 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-29 03:56:32 +0800 |
| commit | 7c20627194284f9c8ac87831917a113fb866900a (patch) | |
| tree | d5f7f045f019aab9af81ccfe6cbadf119a0de98f | |
| parent | ca7527681b609fedc368ea973022b004469035e6 (diff) | |
feat: add proc-macro based `tmpl!` and display block template syntax
This introduces a workspace restructuring with separate library and
proc-macro crates, replacing the old declarative macros with a new proc
macro that supports simplified call syntax, implicit template variable
names, and mixed simple parameters with implementation blocks. Display
blocks (`??? >>> name` / `??? <<<`) provide conditionally included
sections with per-arm control, enabled by inserting a param key. The old
`macro_rules!` macros, deprecated module, and standalone test files are
removed in favor of comprehensive inline tests.
| -rw-r--r-- | CHANGELOG.md | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b659aec..376b2b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,12 +11,43 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Simplified `tmpl!` macro syntax: supports `tmpl!(tmpl, block_name { key = val, ... })` form, removing the `+=` operator and parentheses around each parameter group -- Old syntax `tmpl!(tmpl += { ... })` remains backward compatible +- **Display blocks (`??? >>> name` / `??? <<<`)** — new template syntax for + conditionally included sections. Controlled by `params` key presence: default + hidden, enabled via `template.insert_param("name", "")`. +- **Per-arm display block control** — each implementation arm can independently + enable display blocks by including the block name in its own parameter map, + e.g. `{ crate_name = "you", extra = "" }` enables `??? >>> extra` for that + arm only. +- **`just_template_macros` proc-macro crate** — new `tmpl!` proc macro replaces + the old `macro_rules!` macros (`tmpl!`, `tmpl_param!`), supporting: + - `tmpl!(tmpl, key = val)` and `tmpl! { key = val }` call forms + - Mixed simple parameters and implementation blocks in one call + - Braced multi-parameter arms: `{ key = val, key = val }` inside impl blocks + - Implicit template variable name (defaults to `tmpl` when omitted) +- **Comprehensive test suite** — `test_expand.rs` (direct API tests) and + `test_macros.rs` (macro syntax tests), covering all features. +- `Template::add_impl` now uses `HashMap::entry(...).or_default()` for brevity. +- Public documentation for `Template` fields. ### Changed -- Documentation and test code unified to use the simplified `tmpl!` syntax +- **Restructured to workspace layout** — root `Cargo.toml` is now a workspace + root. Library code moved to `just_template/`, proc-macro code to + `just_template_macros/`. +- **Replaced `macro_rules!` macros with proc macro** — old `tmpl_param!` and + `tmpl!` (declarative) macros are removed in favor of the new `tmpl!` proc + macro from `just_template_macros`. +- **`expand.rs` refactored** — added `apply_display_blocks()`, per-arm display + param merging, migrated from `mem::replace` to `std::mem::take`, and replaced + `.len() < 1` / `.len() > 0` with `.is_empty()` / `!is_empty()`. + +### Removed + +- Old deprecated module (`deprecated.rs`) containing the old `macro_rules!` + macros. +- Standalone test files `test_input.txt` and `test_expect.txt` — replaced by + inline tests in `test_expand.rs`. +- Root-level `src/lib.rs` and `src/test.rs` — moved into workspace crates. ## [0.1.3] - 2026-03-02 |
