MCPcopy Create free account
hub / github.com/eventuallyconsultant/codegenr / call_inner

Method call_inner

codegenr/src/helpers/regex.rs:29–44  ·  view source on GitHub ↗
(
    &self,
    h: &handlebars::Helper<'rc>,
    _: &'reg handlebars::Handlebars<'reg>,
    _: &'rc handlebars::Context,
    _: &mut handlebars::RenderContext<'reg, 'rc>,
  )

Source from the content-addressed store, hash-verified

27
28impl 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.

Callers

nothing calls this directly

Calls 4

get_param_as_strMethod · 0.80
regex_extractMethod · 0.80
regex_transformMethod · 0.80

Tested by

no test coverage detected