aboutsummaryrefslogtreecommitdiff
path: root/just_template/src/template.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-06-29 03:54:54 +0800
committer魏曹先生 <1992414357@qq.com>2026-06-29 03:54:54 +0800
commitca7527681b609fedc368ea973022b004469035e6 (patch)
tree47109782fa5a4435889d93a823db3a4e1f5e7bd6 /just_template/src/template.rs
parentba15b7c06468cb6c52c8d2a53419fd83f9ebcb8b (diff)
feat(just_template): add proc-macro `tmpl!` and restructure crate
Move the old `tmpl!` and `tmpl_param!` macros into a dedicated `just_template_macros` proc-macro crate. The new `tmpl!` macro supports both simple parameter assignment and multi-arm implementation blocks with per-arm overrides. Remove the deprecated `deprecated` module and update tests accordingly.
Diffstat (limited to 'just_template/src/template.rs')
-rw-r--r--just_template/src/template.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/just_template/src/template.rs b/just_template/src/template.rs
index e368917..953d7a5 100644
--- a/just_template/src/template.rs
+++ b/just_template/src/template.rs
@@ -1,9 +1,18 @@
use std::collections::HashMap;
+/// Template struct, used to represent a template composed of a template string and parameters.
+///
+/// # Fields
+/// - `template_str` - Template string containing placeholders.
+/// - `params` - Normal parameters, key-value mappings.
+/// - `impl_params` - Implementation block parameters, where each implementation block name corresponds to a list of parameter maps (each parameter map is a key-value mapping).
#[derive(Default, Clone)]
pub struct Template {
+ /// Template string containing placeholders such as `{{param_name}}`.
pub(crate) template_str: String,
+ /// Normal parameters, keyed by parameter name with values as parameter values.
pub(crate) params: HashMap<String, String>,
+ /// Implementation block parameters, keyed by implementation block name with values as a list of parameter maps.
pub(crate) impl_params: HashMap<String, Vec<HashMap<String, String>>>,
}