aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-04 15:57:49 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-08-04 15:57:49 +0200
commita90b065f46e209f4adb94139c948c8a1bdfaffdf (patch)
tree73e2ffdef7c50b72fbdade8dc0964fe73bbb2cb1 /askama_derive
parent061330d8509fe987abee5b47f035f088f42c386e (diff)
downloadaskama-a90b065f46e209f4adb94139c948c8a1bdfaffdf.tar.gz
askama-a90b065f46e209f4adb94139c948c8a1bdfaffdf.tar.bz2
askama-a90b065f46e209f4adb94139c948c8a1bdfaffdf.zip
Let parse() panic if template is not parsed completely (fixes #27)
Diffstat (limited to '')
-rw-r--r--askama_derive/src/parser.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/askama_derive/src/parser.rs b/askama_derive/src/parser.rs
index d5cea5b..8b5ec4e 100644
--- a/askama_derive/src/parser.rs
+++ b/askama_derive/src/parser.rs
@@ -364,7 +364,14 @@ named!(parse_template<Vec<Node<'a>>>, many0!(alt!(
pub fn parse(src: &str) -> Vec<Node> {
match parse_template(src.as_bytes()) {
- IResult::Done(_, res) => res,
+ IResult::Done(left, res) => {
+ if left.len() > 0 {
+ let s = str::from_utf8(left).unwrap();
+ panic!("unable to parse template:\n\n{:?}", s);
+ } else {
+ res
+ }
+ },
IResult::Error(err) => panic!("problems parsing template source: {}", err),
IResult::Incomplete(_) => panic!("parsing incomplete"),
}