Remove the old partial implementation.
This commit is contained in:
parent
ecf2576a0a
commit
7be00ffea6
@ -33,7 +33,6 @@ pub enum DustTag<'a> {
|
||||
DTNotExists(Container<'a>),
|
||||
DTBlock(NamedBlock<'a>),
|
||||
DTInlinePartial(NamedBlock<'a>),
|
||||
DTPartial(Partial<'a>),
|
||||
DTNewPartial(NewPartial<'a>),
|
||||
DTHelperEquals(ParameterizedBlock<'a>),
|
||||
DTHelperNotEquals(ParameterizedBlock<'a>),
|
||||
@ -119,12 +118,6 @@ pub struct NewPartial<'a> {
|
||||
pub params: Vec<KVPair<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Partial<'a> {
|
||||
pub name: String,
|
||||
pub params: Vec<KVPair<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum OwnedLiteral {
|
||||
LString(String),
|
||||
@ -610,37 +603,6 @@ where
|
||||
move |i: &'a str| map(alt((&plain, "ed)), &constructor)(i)
|
||||
}
|
||||
|
||||
fn partial<'a, F>(
|
||||
open_matcher: &'static str,
|
||||
constructor: F,
|
||||
) -> impl Fn(&'a str) -> IResult<&'a str, DustTag<'a>>
|
||||
where
|
||||
F: Fn(Partial<'a>) -> DustTag<'a>,
|
||||
{
|
||||
move |i: &'a str| {
|
||||
let (i, (name, params)) = delimited(
|
||||
tag(open_matcher),
|
||||
tuple((
|
||||
alt((map(key, String::from), quoted_string)),
|
||||
opt(delimited(
|
||||
space1,
|
||||
separated_list1(space1, key_value_pair),
|
||||
space0,
|
||||
)),
|
||||
)),
|
||||
tag("/}"),
|
||||
)(i)?;
|
||||
|
||||
Ok((
|
||||
i,
|
||||
constructor(Partial {
|
||||
name: name,
|
||||
params: params.unwrap_or(Vec::new()),
|
||||
}),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn filter(i: &str) -> IResult<&str, Filter> {
|
||||
preceded(
|
||||
tag("|"),
|
||||
|
@ -94,7 +94,6 @@ fn extract_inline_partials_from_tag<'a, 'b>(
|
||||
Some(body) => extract_inline_partials_from_body(blocks, &body),
|
||||
};
|
||||
}
|
||||
DustTag::DTPartial(..) => (),
|
||||
DustTag::DTNewPartial(..) => (),
|
||||
DustTag::DTInlinePartial(named_block) => {
|
||||
blocks.insert(&named_block.name, &named_block.contents);
|
||||
|
@ -203,20 +203,6 @@ impl<'a> DustRenderer<'a> {
|
||||
self.render_maybe_body(&container.contents, breadcrumbs, blocks)
|
||||
};
|
||||
}
|
||||
DustTag::DTPartial(partial) => {
|
||||
if partial.params.is_empty() {
|
||||
let rendered_content =
|
||||
self.render_template(&partial.name, breadcrumbs, Some(blocks))?;
|
||||
return Ok(rendered_content);
|
||||
} else {
|
||||
let injected_context = ParametersContext::new(breadcrumbs, &partial.params);
|
||||
let mut new_breadcrumbs = breadcrumbs.clone();
|
||||
new_breadcrumbs.insert(new_breadcrumbs.len() - 1, &injected_context);
|
||||
let rendered_content =
|
||||
self.render_template(&partial.name, &new_breadcrumbs, Some(blocks))?;
|
||||
return Ok(rendered_content);
|
||||
}
|
||||
}
|
||||
DustTag::DTNewPartial(partial) => {
|
||||
let partial_name = self.render_partial_name(&partial.name, breadcrumbs, blocks)?;
|
||||
if partial.params.is_empty() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user