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