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