aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/parser/mod.rs
diff options
context:
space:
mode:
authorLibravatar René Kijewski <rene.kijewski@fu-berlin.de>2023-02-20 11:46:41 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-02-21 13:16:00 +0100
commit70c5784a9ebc1e2f9e97d5358c7b686111ea18f4 (patch)
tree2983982f8a6feaaae9fa5aef0ed3235c981563b4 /askama_derive/src/parser/mod.rs
parent9f3325cbe7901e7d2350c1554029ccaf5ff61621 (diff)
downloadaskama-70c5784a9ebc1e2f9e97d5358c7b686111ea18f4.tar.gz
askama-70c5784a9ebc1e2f9e97d5358c7b686111ea18f4.tar.bz2
askama-70c5784a9ebc1e2f9e97d5358c7b686111ea18f4.zip
Revert "derive: Make Config `'static`"
Diffstat (limited to 'askama_derive/src/parser/mod.rs')
-rw-r--r--askama_derive/src/parser/mod.rs29
1 files changed, 16 insertions, 13 deletions
diff --git a/askama_derive/src/parser/mod.rs b/askama_derive/src/parser/mod.rs
index d345a81..79b178e 100644
--- a/askama_derive/src/parser/mod.rs
+++ b/askama_derive/src/parser/mod.rs
@@ -22,12 +22,12 @@ mod node;
mod tests;
struct State<'a> {
- syntax: &'a Syntax,
+ syntax: &'a Syntax<'a>,
loop_depth: Cell<usize>,
}
-impl State<'_> {
- fn new(syntax: &Syntax) -> State<'_> {
+impl<'a> State<'a> {
+ fn new(syntax: &'a Syntax<'a>) -> State<'a> {
State {
syntax,
loop_depth: Cell::new(0),
@@ -58,7 +58,10 @@ impl From<char> for Whitespace {
}
}
-pub(crate) fn parse<'a>(src: &'a str, syntax: &'a Syntax) -> Result<Vec<Node<'a>>, CompileError> {
+pub(crate) fn parse<'a>(
+ src: &'a str,
+ syntax: &'a Syntax<'_>,
+) -> Result<Vec<Node<'a>>, CompileError> {
match Node::parse(src, &State::new(syntax)) {
Ok((left, res)) => {
if !left.is_empty() {
@@ -271,9 +274,9 @@ fn path(i: &str) -> IResult<&str, Vec<&str>> {
fn take_content<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, Node<'a>> {
let p_start = alt((
- tag(s.syntax.block_start.as_str()),
- tag(s.syntax.comment_start.as_str()),
- tag(s.syntax.expr_start.as_str()),
+ tag(s.syntax.block_start),
+ tag(s.syntax.comment_start),
+ tag(s.syntax.expr_start),
));
let (i, _) = not(eof)(i)?;
@@ -290,25 +293,25 @@ fn take_content<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, Node<'a>> {
}
fn tag_block_start<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, &'a str> {
- tag(s.syntax.block_start.as_str())(i)
+ tag(s.syntax.block_start)(i)
}
fn tag_block_end<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, &'a str> {
- tag(s.syntax.block_end.as_str())(i)
+ tag(s.syntax.block_end)(i)
}
fn tag_comment_start<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, &'a str> {
- tag(s.syntax.comment_start.as_str())(i)
+ tag(s.syntax.comment_start)(i)
}
fn tag_comment_end<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, &'a str> {
- tag(s.syntax.comment_end.as_str())(i)
+ tag(s.syntax.comment_end)(i)
}
fn tag_expr_start<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, &'a str> {
- tag(s.syntax.expr_start.as_str())(i)
+ tag(s.syntax.expr_start)(i)
}
fn tag_expr_end<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, &'a str> {
- tag(s.syntax.expr_end.as_str())(i)
+ tag(s.syntax.expr_end)(i)
}