(
&self,
h: &handlebars::Helper<'rc>,
_: &'reg handlebars::Handlebars<'reg>,
_: &'rc handlebars::Context,
_: &mut handlebars::RenderContext<'reg, 'rc>,
)
| 42 | |
| 43 | impl HelperDef for GlobalParameterHelper { |
| 44 | fn call_inner<'reg: 'rc, 'rc>( |
| 45 | &self, |
| 46 | h: &handlebars::Helper<'reg, 'rc>, |
| 47 | _: &'reg handlebars::Handlebars<'reg>, |
| 48 | _: &'rc handlebars::Context, |
| 49 | _: &mut handlebars::RenderContext<'reg, 'rc>, |
| 50 | ) -> Result<ScopedJson<'reg, 'rc>, RenderError> { |
| 51 | h.ensure_arguments_count_min(1, GLOBAL_PARAMETERS_HELPER)?; |
| 52 | h.ensure_arguments_count_max(2, GLOBAL_PARAMETERS_HELPER)?; |
| 53 | let key = h.get_param_as_str_or_fail(0, GLOBAL_PARAMETERS_HELPER)?.to_string(); |
| 54 | |
| 55 | match self.values.get(&key).cloned() { |
| 56 | Some(v) => Ok(ScopedJson::Derived(v)), |
| 57 | None => { |
| 58 | let strict_mode = h.get_param_as_bool(1).unwrap_or(false); |
| 59 | if strict_mode { |
| 60 | Err(RenderError::new(format!( |
| 61 | "`{}`, error: Cannot find a value for key `{}`", |
| 62 | GLOBAL_PARAMETERS_HELPER, key |
| 63 | ))) |
| 64 | } else { |
| 65 | Ok(ScopedJson::Derived(Default::default())) |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | } |
nothing calls this directly
no test coverage detected