From 8b184511edff62bd3786be3f5d62c1965430278b Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sat, 1 Jul 2023 15:38:34 +0200 Subject: derive: move Syntax into parser module --- askama_derive/src/parser/mod.rs | 24 +++++++++++++++++++++++- askama_derive/src/parser/tests.rs | 3 +-- 2 files changed, 24 insertions(+), 3 deletions(-) (limited to 'askama_derive/src/parser') 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) { -- cgit