(
&self,
h: &handlebars::Helper<'rc>,
_: &'reg handlebars::Handlebars<'reg>,
_: &'rc handlebars::Context,
_: &mut handlebars::RenderContext<'reg, 'rc>,
)
| 27 | |
| 28 | impl HelperDef for RegexExtractHelper { |
| 29 | fn call_inner<'reg: 'rc, 'rc>( |
| 30 | &self, |
| 31 | h: &handlebars::Helper<'reg, 'rc>, |
| 32 | _: &'reg handlebars::Handlebars<'reg>, |
| 33 | _: &'rc handlebars::Context, |
| 34 | _: &mut handlebars::RenderContext<'reg, 'rc>, |
| 35 | ) -> Result<handlebars::ScopedJson<'reg, 'rc>, handlebars::RenderError> { |
| 36 | let arg = h.get_param_as_str_or_fail(0, REGEX_EXTRACT_HELPER)?; |
| 37 | let regex_pattern = h.get_param_as_str_or_fail(1, REGEX_EXTRACT_HELPER)?; |
| 38 | let regex_replacer = h.get_param_as_str_or_fail(2, REGEX_EXTRACT_HELPER)?; |
| 39 | let separator = h.get_param_as_str(3); |
| 40 | let result = arg |
| 41 | .regex_extract(regex_pattern, Some(regex_replacer), separator) |
| 42 | .map_err(|e| RenderError::new(format!("{} error: `{}`.", REGEX_EXTRACT_HELPER, e)))?; |
| 43 | Ok(handlebars::ScopedJson::Derived(Value::String(result))) |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | /// Extract and transform a list of values. |
nothing calls this directly
no test coverage detected