From d044e7a92808bc4264916446093709d1ddca281b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 12 Oct 2017 16:55:03 +0200 Subject: [PATCH] Add helper functions to register all helpers --- lib/core/libimagrt/src/logger.rs | 16 ++-------------- lib/etc/libimaginteraction/src/format.rs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/core/libimagrt/src/logger.rs b/lib/core/libimagrt/src/logger.rs index bad44874..f24516dc 100644 --- a/lib/core/libimagrt/src/logger.rs +++ b/lib/core/libimagrt/src/logger.rs @@ -35,7 +35,6 @@ use log::{Log, LogLevel, LogRecord, LogMetadata}; use toml::Value; use toml_query::read::TomlValueReadExt; use handlebars::Handlebars; -use libimaginteraction::format::*; type ModuleName = String; type Result = ::std::result::Result; @@ -83,19 +82,8 @@ impl ImagLogger { handlebars.register_escape_fn(::handlebars::no_escape); - handlebars.register_helper("black" , Box::new(ColorizeBlackHelper)); - handlebars.register_helper("blue" , Box::new(ColorizeBlueHelper)); - handlebars.register_helper("cyan" , Box::new(ColorizeCyanHelper)); - handlebars.register_helper("green" , Box::new(ColorizeGreenHelper)); - handlebars.register_helper("purple" , Box::new(ColorizePurpleHelper)); - handlebars.register_helper("red" , Box::new(ColorizeRedHelper)); - handlebars.register_helper("white" , Box::new(ColorizeWhiteHelper)); - handlebars.register_helper("yellow" , Box::new(ColorizeYellowHelper)); - - handlebars.register_helper("underline" , Box::new(UnderlineHelper)); - handlebars.register_helper("bold" , Box::new(BoldHelper)); - handlebars.register_helper("blink" , Box::new(BlinkHelper)); - handlebars.register_helper("strikethrough" , Box::new(StrikethroughHelper)); + ::libimaginteraction::format::register_all_color_helpers(&mut handlebars); + ::libimaginteraction::format::register_all_format_helpers(&mut handlebars); { let fmt = try!(aggregate_global_format_trace(matches, config)); diff --git a/lib/etc/libimaginteraction/src/format.rs b/lib/etc/libimaginteraction/src/format.rs index 7c321a6e..4bb6d66d 100644 --- a/lib/etc/libimaginteraction/src/format.rs +++ b/lib/etc/libimaginteraction/src/format.rs @@ -152,3 +152,21 @@ impl HelperDef for StrikethroughHelper { } } +pub fn register_all_color_helpers(handlebars: &mut Handlebars) { + handlebars.register_helper("black" , Box::new(ColorizeBlackHelper)); + handlebars.register_helper("blue" , Box::new(ColorizeBlueHelper)); + handlebars.register_helper("cyan" , Box::new(ColorizeCyanHelper)); + handlebars.register_helper("green" , Box::new(ColorizeGreenHelper)); + handlebars.register_helper("purple" , Box::new(ColorizePurpleHelper)); + handlebars.register_helper("red" , Box::new(ColorizeRedHelper)); + handlebars.register_helper("white" , Box::new(ColorizeWhiteHelper)); + handlebars.register_helper("yellow" , Box::new(ColorizeYellowHelper)); +} + +pub fn register_all_format_helpers(handlebars: &mut Handlebars) { + handlebars.register_helper("underline" , Box::new(UnderlineHelper)); + handlebars.register_helper("bold" , Box::new(BoldHelper)); + handlebars.register_helper("blink" , Box::new(BlinkHelper)); + handlebars.register_helper("strikethrough" , Box::new(StrikethroughHelper)); +} +