Delete the old new_breadcrumbs function that is no longer used.
This commit is contained in:
parent
d07ac3dcc9
commit
0236f882b7
@ -693,91 +693,6 @@ impl<'a> DustRenderer<'a> {
|
|||||||
final_filters
|
final_filters
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate a new breadcrumbs object
|
|
||||||
///
|
|
||||||
/// This function generates a new breadcrumbs object based on the
|
|
||||||
/// new context information provided.
|
|
||||||
///
|
|
||||||
/// breadcrumbs are the breadcrumbs that will be used in the final
|
|
||||||
/// breadcrumbs (unless omitted due to an explicit context)
|
|
||||||
///
|
|
||||||
/// explicit_context_breadcrumbs are the breadcrumbs used to
|
|
||||||
/// evaluate an explicit context path. Most of the time the two
|
|
||||||
/// breadcrumbs parameters will be identical, but for
|
|
||||||
/// blocks/inline partials the explicit_context_breadcrumbs will
|
|
||||||
/// be the breadcrumbs from the start of the partial containing
|
|
||||||
/// the block.
|
|
||||||
///
|
|
||||||
/// explicit_context is for contexts specified with a `:path`
|
|
||||||
/// inside a dust tag.
|
|
||||||
///
|
|
||||||
/// injected_context is for any generated context. This includes
|
|
||||||
/// both parameters on a tag and also the handling of $idx and
|
|
||||||
/// $len.
|
|
||||||
///
|
|
||||||
/// New context element is the element is an element to append to
|
|
||||||
/// the end, generally for use in section tags which walk to a new
|
|
||||||
/// context.
|
|
||||||
///
|
|
||||||
/// If explicit_context is not None, then the final breadcrumb stack will be:
|
|
||||||
///
|
|
||||||
/// ```text
|
|
||||||
/// breadcrumbs
|
|
||||||
/// injected_context
|
|
||||||
/// new_context_element
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// However, if explicit_context is not None, then the old
|
|
||||||
/// breadcrumbs are omitted, leading to the new breadcrumb stack
|
|
||||||
/// as:
|
|
||||||
///
|
|
||||||
/// ```text
|
|
||||||
/// injected_context
|
|
||||||
/// explicit_context
|
|
||||||
/// new_context_element
|
|
||||||
/// ```
|
|
||||||
fn new_breadcrumbs_deprecated<'b>(
|
|
||||||
breadcrumbs: &'b Vec<&'b dyn ContextElement>,
|
|
||||||
explicit_context_breadcrumbs: &'b Vec<&'b dyn ContextElement>,
|
|
||||||
injected_context: Option<&'b dyn ContextElement>,
|
|
||||||
explicit_context: &Option<Path<'b>>,
|
|
||||||
new_context_element: Option<&'b dyn ContextElement>,
|
|
||||||
) -> Option<Vec<&'b dyn ContextElement>> {
|
|
||||||
// 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 (injected_context, explicit_context, new_context_element) {
|
|
||||||
(None, None, None) => return None,
|
|
||||||
_ => (),
|
|
||||||
};
|
|
||||||
let mut new_stack = match explicit_context {
|
|
||||||
Some(_) => Vec::with_capacity(3),
|
|
||||||
None => breadcrumbs.clone(),
|
|
||||||
};
|
|
||||||
// TODO: Can sections have parameters, and if so, what happens then? Currently when there is an injected context or an explicit context it gets inserted behind the current context, so 1->2->3 becomes 1->2->injected->3 or explicit->3. When there is a new context(4) with injected we're doing 1->2->3->injected->4. When there is an explicit context and a new context we're doing explicit->4. But what happens if there is a section with parameters and an explicit context, hitting all the categories? Would it be parameters->explicit->4? I would definitely have to change the parameters to this function since right now iteration variables and parameters are both sharing injected_context.
|
|
||||||
injected_context.map(|ctx| {
|
|
||||||
// Special case: when there is no explicit context or new
|
|
||||||
// context element, the injected context gets inserted 1
|
|
||||||
// spot behind the current context. Otherwise, the
|
|
||||||
// injected context gets added after the current context
|
|
||||||
// but before the explicit context and new context
|
|
||||||
// element.
|
|
||||||
match (explicit_context, new_context_element) {
|
|
||||||
(None, None) => new_stack.insert(std::cmp::max(new_stack.len() - 1, 0), ctx),
|
|
||||||
_ => new_stack.push(ctx),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
explicit_context.as_ref().map(|path| {
|
|
||||||
walk_path(explicit_context_breadcrumbs, &path.keys).map(|val| {
|
|
||||||
if val.is_truthy() {
|
|
||||||
new_stack.push(val)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
new_context_element.map(|ctx| new_stack.push(ctx));
|
|
||||||
Some(new_stack)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn new_breadcrumbs_section<'b>(
|
fn new_breadcrumbs_section<'b>(
|
||||||
breadcrumbs: &'b Vec<&'b dyn ContextElement>,
|
breadcrumbs: &'b Vec<&'b dyn ContextElement>,
|
||||||
index_context: Option<&'b dyn ContextElement>,
|
index_context: Option<&'b dyn ContextElement>,
|
||||||
@ -814,15 +729,6 @@ impl<'a> DustRenderer<'a> {
|
|||||||
Some(new_stack)
|
Some(new_stack)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_index_of_first_non_pseudo_element<'b, B>(breadcrumbs: &'b Vec<B>) -> Option<usize>
|
|
||||||
where
|
|
||||||
B: Borrow<dyn ContextElement + 'a>,
|
|
||||||
{
|
|
||||||
breadcrumbs
|
|
||||||
.iter()
|
|
||||||
.rposition(|b| !(*b).borrow().is_pseudo_element())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn new_breadcrumbs_partial<'b>(
|
fn new_breadcrumbs_partial<'b>(
|
||||||
breadcrumbs: &'b Vec<&'b dyn ContextElement>,
|
breadcrumbs: &'b Vec<&'b dyn ContextElement>,
|
||||||
explicit_context_breadcrumbs: &'b Vec<&'b dyn ContextElement>,
|
explicit_context_breadcrumbs: &'b Vec<&'b dyn ContextElement>,
|
||||||
@ -863,6 +769,15 @@ impl<'a> DustRenderer<'a> {
|
|||||||
});
|
});
|
||||||
Some(new_stack)
|
Some(new_stack)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_index_of_first_non_pseudo_element<'b, B>(breadcrumbs: &'b Vec<B>) -> Option<usize>
|
||||||
|
where
|
||||||
|
B: Borrow<dyn ContextElement + 'a>,
|
||||||
|
{
|
||||||
|
breadcrumbs
|
||||||
|
.iter()
|
||||||
|
.rposition(|b| !(*b).borrow().is_pseudo_element())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BlockContext<'a> {
|
struct BlockContext<'a> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user