Skip to content

Commit

Permalink
Minor parser improvement.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaj committed Mar 11, 2018
1 parent 6d0fadd commit 29dac3d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/templateexpression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ named!(
alt!(tag!(":") | tag!("{") | tag!("}") |
terminated!(
alt!(tag!("if") | tag!("for")),
tag!(" "))))),
tag!(" ")) |
value!(&b""[..])))),
Some(b":") => map!(
pair!(rust_name,
delimited!(tag!("("),
Expand Down Expand Up @@ -239,14 +240,16 @@ named!(
expr: expr,
body: body,
}) |
Some(b"") => map!(
expression,
|expr| TemplateExpression::Expression{ expr: expr }
) |
None => alt!(
map!(comment, |()| TemplateExpression::Comment) |
map!(is_not!("@{}"),
|text| TemplateExpression::Text {
text: from_utf8(text).unwrap().to_string()
}) |
map!(preceded!(tag!("@"), expression),
|expr| TemplateExpression::Expression{ expr: expr })
})
)
))
);
Expand Down

0 comments on commit 29dac3d

Please sign in to comment.