All but explicit context for new_breadcrumbs_section.
This commit is contained in:
parent
b381789422
commit
de5914417e
@ -44,6 +44,15 @@ impl<'a> DustRenderer<'a> {
|
|||||||
.insert(template.name.clone(), &template.template);
|
.insert(template.name.clone(), &template.template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a option of a tuple of (parent, new_node_elements)
|
||||||
|
/// which can then be formed into new BreadcrumbTreeNodes
|
||||||
|
///
|
||||||
|
/// If None is returned, then it is a signal to simply re-use the
|
||||||
|
/// existing breadcrumbs.
|
||||||
|
///
|
||||||
|
/// Otherwise, the parent (which may be None, especially for
|
||||||
|
/// explicit contexts) and the additional node elements (which may
|
||||||
|
/// be empty) should be combined into a final BreadcrumbTreeNode
|
||||||
fn new_breadcrumbs_section<'b>(
|
fn new_breadcrumbs_section<'b>(
|
||||||
&self,
|
&self,
|
||||||
maybe_breadcrumbs: Option<&'a BreadcrumbTreeNode>,
|
maybe_breadcrumbs: Option<&'a BreadcrumbTreeNode>,
|
||||||
@ -51,15 +60,20 @@ impl<'a> DustRenderer<'a> {
|
|||||||
injected_context: Option<&'b dyn IntoContextElement>,
|
injected_context: Option<&'b dyn IntoContextElement>,
|
||||||
explicit_context: &Option<Path<'b>>,
|
explicit_context: &Option<Path<'b>>,
|
||||||
new_context_element: Option<&'b dyn ContextElement>,
|
new_context_element: Option<&'b dyn ContextElement>,
|
||||||
) -> Option<&'a BreadcrumbTreeNode> {
|
) -> Option<(
|
||||||
// If there is no new content, return the original breadcrumbs
|
Option<&'b BreadcrumbTreeNode>,
|
||||||
|
Vec<BreadcrumbTreeNodeElement<'b>>,
|
||||||
|
)> {
|
||||||
|
// If none of the additional contexts are present, return None
|
||||||
|
// to signal that the original breadcrumbs should be used
|
||||||
|
// rather than incurring a copy here.
|
||||||
match (
|
match (
|
||||||
index_context,
|
index_context,
|
||||||
injected_context,
|
injected_context,
|
||||||
explicit_context,
|
explicit_context,
|
||||||
new_context_element,
|
new_context_element,
|
||||||
) {
|
) {
|
||||||
(None, None, None, None) => return maybe_breadcrumbs,
|
(None, None, None, None) => return None,
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,17 +83,18 @@ impl<'a> DustRenderer<'a> {
|
|||||||
Some(_) => None,
|
Some(_) => None,
|
||||||
None => maybe_breadcrumbs,
|
None => maybe_breadcrumbs,
|
||||||
};
|
};
|
||||||
let mut new_stack = None;
|
let mut new_nodes = Vec::new();
|
||||||
|
|
||||||
// TODO: Explicit context
|
// TODO: Explicit context
|
||||||
|
|
||||||
injected_context.map(|ctx| {
|
injected_context.map(|ctx| new_nodes.push(BreadcrumbTreeNodeElement::Borrowed(ctx)));
|
||||||
new_stack = Some(BreadcrumbTreeNode::new(
|
new_context_element.map(|ctx| {
|
||||||
parent.map(|b| b as _),
|
new_nodes.push(BreadcrumbTreeNodeElement::Borrowed(
|
||||||
BreadcrumbTreeNodeElement::Borrowed(ctx),
|
ctx.from_context_element(),
|
||||||
))
|
))
|
||||||
});
|
});
|
||||||
|
index_context.map(|ctx| new_nodes.push(BreadcrumbTreeNodeElement::Borrowed(ctx)));
|
||||||
|
|
||||||
None
|
Some((parent, new_nodes))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user