Integrate the new_breadcrumbs function into sections.
This commit is contained in:
parent
d79447e602
commit
32c047a9b9
@ -188,9 +188,17 @@ impl<'a> DustRenderer<'a> {
|
||||
final_val.get_loop_elements();
|
||||
if loop_elements.is_empty() {
|
||||
// Scalar value
|
||||
let mut new_breadcrumbs = breadcrumbs.clone();
|
||||
new_breadcrumbs.push(final_val);
|
||||
self.render_body(body, &new_breadcrumbs, blocks)
|
||||
let new_breadcrumbs = Self::new_breadcrumbs(
|
||||
breadcrumbs,
|
||||
None,
|
||||
&container.explicit_context,
|
||||
Some(final_val),
|
||||
);
|
||||
self.render_body(
|
||||
body,
|
||||
new_breadcrumbs.as_ref().unwrap_or(breadcrumbs),
|
||||
blocks,
|
||||
)
|
||||
} else {
|
||||
// Array-like value
|
||||
let total_length = loop_elements.len();
|
||||
@ -201,12 +209,17 @@ impl<'a> DustRenderer<'a> {
|
||||
.map(|(i, array_elem)| {
|
||||
let injected_context =
|
||||
IterationContext::new(i, total_length);
|
||||
let mut new_breadcrumbs = breadcrumbs.clone();
|
||||
new_breadcrumbs.push(&injected_context);
|
||||
new_breadcrumbs.push(array_elem);
|
||||
let new_breadcrumbs = Self::new_breadcrumbs(
|
||||
breadcrumbs,
|
||||
Some(&injected_context),
|
||||
&container.explicit_context,
|
||||
Some(array_elem),
|
||||
);
|
||||
self.render_body(
|
||||
&body,
|
||||
&new_breadcrumbs,
|
||||
new_breadcrumbs
|
||||
.as_ref()
|
||||
.unwrap_or(breadcrumbs),
|
||||
blocks,
|
||||
)
|
||||
})
|
||||
@ -221,9 +234,15 @@ impl<'a> DustRenderer<'a> {
|
||||
// an empty array or null), Dust uses the
|
||||
// original context before walking the path as
|
||||
// the context for rendering the else block
|
||||
let new_breadcrumbs = Self::new_breadcrumbs(
|
||||
breadcrumbs,
|
||||
None,
|
||||
&container.explicit_context,
|
||||
None,
|
||||
);
|
||||
return self.render_maybe_body(
|
||||
&container.else_contents,
|
||||
breadcrumbs,
|
||||
new_breadcrumbs.as_ref().unwrap_or(breadcrumbs),
|
||||
blocks,
|
||||
);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user