diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2023-07-02 10:53:15 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2023-07-31 10:27:15 +0200 |
commit | bdb6c0b89df5099fe6cf2e79e04e0efd21f64aa8 (patch) | |
tree | b9721a20cc0d665d301673e35a6d51cd23c8a46d | |
parent | 1a9f5a16fb54d6c75a8e36aafa9703cc29a0a76a (diff) | |
download | askama-bdb6c0b89df5099fe6cf2e79e04e0efd21f64aa8.tar.gz askama-bdb6c0b89df5099fe6cf2e79e04e0efd21f64aa8.tar.bz2 askama-bdb6c0b89df5099fe6cf2e79e04e0efd21f64aa8.zip |
derive: move whitespace conversion into config module
-rw-r--r-- | askama_derive/src/config.rs | 12 | ||||
-rw-r--r-- | askama_derive/src/parser/node.rs | 11 |
2 files changed, 11 insertions, 12 deletions
diff --git a/askama_derive/src/config.rs b/askama_derive/src/config.rs index 1fee3c8..e456c67 100644 --- a/askama_derive/src/config.rs +++ b/askama_derive/src/config.rs @@ -5,7 +5,7 @@ use std::{env, fs}; #[cfg(feature = "serde")] use serde::Deserialize; -use crate::parser::Syntax; +use crate::parser::{Syntax, Whitespace}; use crate::CompileError; #[derive(Debug)] @@ -215,6 +215,16 @@ pub(crate) enum WhitespaceHandling { Minimize, } +impl From<WhitespaceHandling> for Whitespace { + fn from(ws: WhitespaceHandling) -> Self { + match ws { + WhitespaceHandling::Suppress => Whitespace::Suppress, + WhitespaceHandling::Preserve => Whitespace::Preserve, + WhitespaceHandling::Minimize => Whitespace::Minimize, + } + } +} + impl Default for WhitespaceHandling { fn default() -> Self { WhitespaceHandling::Preserve diff --git a/askama_derive/src/parser/node.rs b/askama_derive/src/parser/node.rs index 8c122af..ce303bc 100644 --- a/askama_derive/src/parser/node.rs +++ b/askama_derive/src/parser/node.rs @@ -14,7 +14,6 @@ use super::{ tag_block_end, tag_block_start, tag_comment_end, tag_comment_start, tag_expr_end, tag_expr_start, take_content, ws, Expr, State, }; -use crate::config::WhitespaceHandling; #[derive(Debug, PartialEq)] pub(crate) enum Node<'a> { @@ -56,16 +55,6 @@ pub(crate) enum Whitespace { Minimize, } -impl From<WhitespaceHandling> for Whitespace { - fn from(ws: WhitespaceHandling) -> Self { - match ws { - WhitespaceHandling::Suppress => Whitespace::Suppress, - WhitespaceHandling::Preserve => Whitespace::Preserve, - WhitespaceHandling::Minimize => Whitespace::Minimize, - } - } -} - #[derive(Debug, PartialEq)] pub(crate) struct Loop<'a> { pub(crate) ws1: Ws, |