diff options
author | René Kijewski <kijewski@library.vetmed.fu-berlin.de> | 2022-01-31 12:02:02 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2022-01-31 13:11:54 +0100 |
commit | 0e9c9aeb9ddf8b86eeb86e1822f7285f65bc0b9d (patch) | |
tree | badc796b1ea333b0f6abc07f97dac6f5795bfe76 /askama_shared | |
parent | b42ff339387af697f35cc8b630ac98aaaf68ac2c (diff) | |
download | askama-0e9c9aeb9ddf8b86eeb86e1822f7285f65bc0b9d.tar.gz askama-0e9c9aeb9ddf8b86eeb86e1822f7285f65bc0b9d.tar.bz2 askama-0e9c9aeb9ddf8b86eeb86e1822f7285f65bc0b9d.zip |
Don't wrap in StrLit just to extract the str imm.
Diffstat (limited to 'askama_shared')
-rw-r--r-- | askama_shared/src/parser.rs | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/askama_shared/src/parser.rs b/askama_shared/src/parser.rs index 97ccf6c..900e71a 100644 --- a/askama_shared/src/parser.rs +++ b/askama_shared/src/parser.rs @@ -966,19 +966,10 @@ fn block_include(i: &str) -> IResult<&str, Node<'_>> { let mut p = tuple(( opt(char('-')), ws(tag("include")), - cut(pair(ws(expr_str_lit), opt(char('-')))), + cut(pair(ws(str_lit), opt(char('-')))), )); let (i, (pws, _, (name, nws))) = p(i)?; - Ok(( - i, - Node::Include( - Ws(pws.is_some(), nws.is_some()), - match name { - Expr::StrLit(s) => s, - _ => panic!("include path must be a string literal"), - }, - ), - )) + Ok((i, Node::Include(Ws(pws.is_some(), nws.is_some()), name))) } fn block_import(i: &str) -> IResult<&str, Node<'_>> { @@ -986,7 +977,7 @@ fn block_import(i: &str) -> IResult<&str, Node<'_>> { opt(char('-')), ws(tag("import")), cut(tuple(( - ws(expr_str_lit), + ws(str_lit), ws(tag("as")), cut(pair(ws(identifier), opt(char('-')))), ))), @@ -994,14 +985,7 @@ fn block_import(i: &str) -> IResult<&str, Node<'_>> { let (i, (pws, _, (name, _, (scope, nws)))) = p(i)?; Ok(( i, - Node::Import( - Ws(pws.is_some(), nws.is_some()), - match name { - Expr::StrLit(s) => s, - _ => panic!("import path must be a string literal"), - }, - scope, - ), + Node::Import(Ws(pws.is_some(), nws.is_some()), name, scope), )) } |