mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-17 06:01:21 +01:00
Handle enabled/disabled variables and render multi
This commit is contained in:
1 parent
a44e88f53d
commit
677f436bcb
2 files changed
+9
-3
No files matched your search
@@ -13,12 +13,18 @@ fn render_with_environment(template: &str, environment: &Environment) -> String
|
||||
let mut map = HashMap::new();
|
||||
let variables = &environment.variables.0;
|
||||
for variable in variables {
|
||||
map.insert(variable.name.as_str(), variable.value.as_str());
|
||||
if !variable.enabled {
|
||||
continue;
|
||||
}
|
||||
map.insert(
|
||||
variable.name.as_str(),
|
||||
variable.value.as_str(),
|
||||
);
|
||||
}
|
||||
|
||||
Regex::new(r"\$\{\[\s*([^]\s]+)\s*]}")
|
||||
.expect("Failed to create regex")
|
||||
.replace(template, |caps: &tauri::regex::Captures| {
|
||||
.replace_all(template, |caps: &tauri::regex::Captures| {
|
||||
let key = caps.get(1).unwrap().as_str();
|
||||
map.get(key).unwrap_or(&"")
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user