Rename Block to Body because dust uses the name Block for {+
This commit is contained in:
parent
fb17911c44
commit
7f2c7151a9
@ -71,18 +71,18 @@ struct Span<'a> {
|
|||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
struct Container<'a> {
|
struct Container<'a> {
|
||||||
path: Path<'a>,
|
path: Path<'a>,
|
||||||
contents: Option<Block<'a>>,
|
contents: Option<Body<'a>>,
|
||||||
else_contents: Option<Block<'a>>,
|
else_contents: Option<Body<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
struct Block<'a> {
|
struct Body<'a> {
|
||||||
elements: Vec<TemplateElement<'a>>,
|
elements: Vec<TemplateElement<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Template<'a> {
|
pub struct Template<'a> {
|
||||||
contents: Block<'a>,
|
contents: Body<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
@ -172,8 +172,8 @@ where
|
|||||||
let (i, (opening_name, inner, maybe_else, _closing_name)) = verify(
|
let (i, (opening_name, inner, maybe_else, _closing_name)) = verify(
|
||||||
tuple((
|
tuple((
|
||||||
delimited(tag(open_matcher), path, tag("}")),
|
delimited(tag(open_matcher), path, tag("}")),
|
||||||
opt(block),
|
opt(body),
|
||||||
opt(preceded(tag("{:else}"), opt(block))),
|
opt(preceded(tag("{:else}"), opt(body))),
|
||||||
delimited(tag("{/"), path, tag("}")),
|
delimited(tag("{/"), path, tag("}")),
|
||||||
)),
|
)),
|
||||||
|(open, _inn, _maybe_else, close)| open == close,
|
|(open, _inn, _maybe_else, close)| open == close,
|
||||||
@ -232,21 +232,21 @@ fn span(i: &str) -> IResult<&str, Span> {
|
|||||||
Ok((remaining, Span { contents: body }))
|
Ok((remaining, Span { contents: body }))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block(i: &str) -> IResult<&str, Block> {
|
fn body(i: &str) -> IResult<&str, Body> {
|
||||||
let (remaining, template_elements) = many1(alt((
|
let (remaining, template_elements) = many1(alt((
|
||||||
map(span, TemplateElement::TESpan),
|
map(span, TemplateElement::TESpan),
|
||||||
map(dust_tag, TemplateElement::TETag),
|
map(dust_tag, TemplateElement::TETag),
|
||||||
)))(i)?;
|
)))(i)?;
|
||||||
Ok((
|
Ok((
|
||||||
remaining,
|
remaining,
|
||||||
Block {
|
Body {
|
||||||
elements: template_elements,
|
elements: template_elements,
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn template(i: &str) -> IResult<&str, Template> {
|
pub fn template(i: &str) -> IResult<&str, Template> {
|
||||||
let (remaining, contents) = block(i)?;
|
let (remaining, contents) = body(i)?;
|
||||||
Ok((remaining, Template { contents: contents }))
|
Ok((remaining, Template { contents: contents }))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,7 +404,7 @@ mod tests {
|
|||||||
path: Path {
|
path: Path {
|
||||||
keys: vec!["foo", "bar"]
|
keys: vec!["foo", "bar"]
|
||||||
},
|
},
|
||||||
contents: Some(Block {
|
contents: Some(Body {
|
||||||
elements: vec![
|
elements: vec![
|
||||||
TemplateElement::TESpan(Span { contents: "hello " }),
|
TemplateElement::TESpan(Span { contents: "hello " }),
|
||||||
TemplateElement::TETag(DustTag::DTReference(Reference {
|
TemplateElement::TETag(DustTag::DTReference(Reference {
|
||||||
@ -429,7 +429,7 @@ mod tests {
|
|||||||
path: Path {
|
path: Path {
|
||||||
keys: vec!["greeting"]
|
keys: vec!["greeting"]
|
||||||
},
|
},
|
||||||
contents: Some(Block {
|
contents: Some(Body {
|
||||||
elements: vec![
|
elements: vec![
|
||||||
TemplateElement::TESpan(Span { contents: "hello " }),
|
TemplateElement::TESpan(Span { contents: "hello " }),
|
||||||
TemplateElement::TETag(DustTag::DTReference(Reference {
|
TemplateElement::TETag(DustTag::DTReference(Reference {
|
||||||
@ -438,7 +438,7 @@ mod tests {
|
|||||||
}))
|
}))
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
else_contents: Some(Block {
|
else_contents: Some(Body {
|
||||||
elements: vec![
|
elements: vec![
|
||||||
TemplateElement::TESpan(Span {
|
TemplateElement::TESpan(Span {
|
||||||
contents: "goodbye "
|
contents: "goodbye "
|
||||||
|
Loading…
Reference in New Issue
Block a user