Add helper functions to register all helpers

This commit is contained in:
Matthias Beyer 2017-10-12 16:55:03 +02:00
parent eb07bce1d0
commit d044e7a928
2 changed files with 20 additions and 14 deletions

View file

@ -35,7 +35,6 @@ use log::{Log, LogLevel, LogRecord, LogMetadata};
use toml::Value; use toml::Value;
use toml_query::read::TomlValueReadExt; use toml_query::read::TomlValueReadExt;
use handlebars::Handlebars; use handlebars::Handlebars;
use libimaginteraction::format::*;
type ModuleName = String; type ModuleName = String;
type Result<T> = ::std::result::Result<T, RE>; type Result<T> = ::std::result::Result<T, RE>;
@ -83,19 +82,8 @@ impl ImagLogger {
handlebars.register_escape_fn(::handlebars::no_escape); handlebars.register_escape_fn(::handlebars::no_escape);
handlebars.register_helper("black" , Box::new(ColorizeBlackHelper)); ::libimaginteraction::format::register_all_color_helpers(&mut handlebars);
handlebars.register_helper("blue" , Box::new(ColorizeBlueHelper)); ::libimaginteraction::format::register_all_format_helpers(&mut handlebars);
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));
{ {
let fmt = try!(aggregate_global_format_trace(matches, config)); let fmt = try!(aggregate_global_format_trace(matches, config));

View file

@ -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));
}