diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2023-07-01 15:38:34 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2023-07-31 10:27:15 +0200 |
commit | 8b184511edff62bd3786be3f5d62c1965430278b (patch) | |
tree | 340209532d26c9f177ba21fd1e444ea6f24f37a7 /askama_derive/src/parser | |
parent | ac8de6260e34c7dc7f7f2228e832d1860a31707d (diff) | |
download | askama-8b184511edff62bd3786be3f5d62c1965430278b.tar.gz askama-8b184511edff62bd3786be3f5d62c1965430278b.tar.bz2 askama-8b184511edff62bd3786be3f5d62c1965430278b.zip |
derive: move Syntax into parser module
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/parser/mod.rs | 24 | ||||
-rw-r--r-- | askama_derive/src/parser/tests.rs | 3 |
2 files changed, 24 insertions, 3 deletions
diff --git a/askama_derive/src/parser/mod.rs b/askama_derive/src/parser/mod.rs index ccc9ff9..f81bcc8 100644 --- a/askama_derive/src/parser/mod.rs +++ b/askama_derive/src/parser/mod.rs @@ -13,7 +13,6 @@ use nom::{error_position, AsChar, IResult, InputTakeAtPosition}; pub(crate) use self::expr::Expr; pub(crate) use self::node::{Cond, CondTest, Loop, Macro, Node, Target, When, Whitespace, Ws}; -use crate::config::Syntax; use crate::CompileError; mod expr; @@ -312,3 +311,26 @@ fn tag_expr_start<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, &'a str> { fn tag_expr_end<'a>(i: &'a str, s: &State<'_>) -> IResult<&'a str, &'a str> { tag(s.syntax.expr_end)(i) } + +#[derive(Debug)] +pub(crate) struct Syntax<'a> { + pub(crate) block_start: &'a str, + pub(crate) block_end: &'a str, + pub(crate) expr_start: &'a str, + pub(crate) expr_end: &'a str, + pub(crate) comment_start: &'a str, + pub(crate) comment_end: &'a str, +} + +impl Default for Syntax<'static> { + fn default() -> Self { + Self { + block_start: "{%", + block_end: "%}", + expr_start: "{{", + expr_end: "}}", + comment_start: "{#", + comment_end: "#}", + } + } +} diff --git a/askama_derive/src/parser/tests.rs b/askama_derive/src/parser/tests.rs index 801e787..68cf14b 100644 --- a/askama_derive/src/parser/tests.rs +++ b/askama_derive/src/parser/tests.rs @@ -1,5 +1,4 @@ -use crate::config::Syntax; -use crate::parser::{Expr, Node, Whitespace, Ws}; +use super::{Expr, Node, Syntax, Whitespace, Ws}; fn check_ws_split(s: &str, res: &(&str, &str, &str)) { match super::split_ws_parts(s) { |