Skip to content

Commit

Permalink
fix(template): include for-loop arguments in template variables (#812)
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun authored Aug 23, 2024
1 parent 3b6156d commit 9a6430b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions git-cliff-core/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ impl Template {
for node in &forloop.empty_body.clone().unwrap_or_default() {
Self::find_identifiers(node, names);
}
for (_, expr) in
forloop.container.filters.iter().flat_map(|v| v.args.iter())
{
if let ast::ExprVal::String(ref v) = expr.val {
names.insert(v.clone());
}
}
}
ast::Node::If(cond, _) => {
for (_, expr, nodes) in &cond.conditions {
Expand Down Expand Up @@ -128,6 +135,7 @@ impl Template {
for node in ast {
Self::find_identifiers(node, &mut variables);
}
trace!("Template variables: {variables:?}");
Ok(variables.into_iter().collect())
}

Expand Down

0 comments on commit 9a6430b

Please sign in to comment.