sqruff_lib/templaters/
raw.rs1use std::sync::Arc;
2
3use sqruff_lib_core::errors::SQLFluffUserError;
4use sqruff_lib_core::templaters::TemplatedFile;
5
6use crate::Formatter;
7use crate::core::config::FluffConfig;
8use crate::templaters::Templater;
9
10#[derive(Default)]
11pub struct RawTemplater;
12
13impl Templater for RawTemplater {
14 fn name(&self) -> &'static str {
15 "raw"
16 }
17
18 fn can_process_in_parallel(&self) -> bool {
19 true
20 }
21
22 fn description(&self) -> &'static str {
23 r"The raw templater simply returns the input string as the output string. It passes through the input string unchanged and is useful if you need no templating. It is the default templater."
24 }
25
26 fn process(
27 &self,
28 in_str: &str,
29 f_name: &str,
30 _config: &FluffConfig,
31 _formatter: &Option<Arc<dyn Formatter>>,
32 ) -> Result<TemplatedFile, SQLFluffUserError> {
33 if let Ok(tf) = TemplatedFile::new(in_str.to_string(), f_name.to_string(), None, None, None)
34 {
35 return Ok(tf);
36 }
37 panic!("Not implemented")
38 }
39}
40
41#[cfg(test)]
42mod test {
43 use super::*;
44
45 #[test]
46 fn test_templater_raw() {
48 let templater = RawTemplater;
49 let in_str = "SELECT * FROM {{blah}}";
50
51 let outstr = templater
52 .process(
53 in_str,
54 "test.sql",
55 &FluffConfig::from_source("", None),
56 &None,
57 )
58 .unwrap();
59
60 assert_eq!(outstr.templated_str, Some(in_str.to_string()));
61 }
62}