diff --git a/src/parser/parser.rs b/src/parser/parser.rs index 026e98b..b2d9add 100644 --- a/src/parser/parser.rs +++ b/src/parser/parser.rs @@ -71,18 +71,18 @@ struct Span<'a> { #[derive(Clone, Debug, PartialEq)] struct Container<'a> { path: Path<'a>, - contents: Option>, - else_contents: Option>, + contents: Option>, + else_contents: Option>, } #[derive(Clone, Debug, PartialEq)] -struct Block<'a> { +struct Body<'a> { elements: Vec>, } #[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 "