summaryrefslogtreecommitdiffstats
path: root/crates/driver/src/template.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/driver/src/template.rs')
-rw-r--r--crates/driver/src/template.rs44
1 files changed, 0 insertions, 44 deletions
diff --git a/crates/driver/src/template.rs b/crates/driver/src/template.rs
deleted file mode 100644
index b663e7d..0000000
--- a/crates/driver/src/template.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-use handlebars::Handlebars;
-use lazy_static::lazy_static;
-
-use common::error::*;
-
-use crate::args::TaskArgs;
-
-fn escape(s: &str) -> String {
- format!("'{}'", s.replace("'", "'\\''"))
-}
-
-#[derive(Debug)]
-pub struct TemplateEngine {
- tpl: Handlebars<'static>,
- tpl_raw: Handlebars<'static>,
-}
-
-impl TemplateEngine {
- pub fn new() -> Self {
- let mut tpl = Handlebars::new();
- tpl.set_strict_mode(true);
- tpl.register_escape_fn(escape);
-
- let mut tpl_raw = Handlebars::new();
- tpl_raw.set_strict_mode(true);
- tpl_raw.register_escape_fn(handlebars::no_escape);
-
- TemplateEngine { tpl, tpl_raw }
- }
-
- pub fn eval_raw(&self, input: &str, args: &TaskArgs) -> Result<String> {
- self.tpl_raw
- .render_template(input, args)
- .map_err(Error::new)
- }
-
- pub fn eval(&self, input: &str, args: &TaskArgs) -> Result<String> {
- self.tpl.render_template(input, args).map_err(Error::new)
- }
-}
-
-lazy_static! {
- pub static ref ENGINE: TemplateEngine = TemplateEngine::new();
-}