MCPcopy Index your code
hub / github.com/eventuallyconsultant/codegenr / call

Method call

codegenr/src/helpers/strings.rs:184–201  ·  view source on GitHub ↗
(
    &self,
    h: &handlebars::Helper<'rc>,
    handle: &'reg handlebars::Handlebars<'reg>,
    ctx: &'rc handlebars::Context,
    render_ctx: &mut handlebars::RenderContext<'reg, 'rc>,
    out: &mu

Source from the content-addressed store, hash-verified

182 let to_trim = h.get_param_as_str_or_fail(0, TRIM_END_HELPER)?;
183 let splitter = h.get_param_as_str(1).map(|s| s.to_string());
184 Ok(handlebars::ScopedJson::Derived(Value::String(to_trim.trim_end_char(splitter))))
185 }
186}
187
188/// Determines whether the beginning of the second argumentmatches the second one
189///```
190/// # use codegenr_lib::helpers::*;
191/// # use serde_json::json;
192/// assert_eq!(
193/// exec_template(json!({"one": "test-one", "two": "one-test"}), r#"{{#start_with "test" one}}OK{{else}}{{/start_with}}"#),
194/// "OK"
195/// );
196/// assert_eq!(
197/// exec_template(json!({"one": "test-one", "two": "one-test"}), r#"{{#start_with "test" two}}OK{{else}}NOK{{/start_with}}"#),
198/// "NOK"
199/// );
200///```
201pub struct StartWithHelper;
202
203impl HelperDef for StartWithHelper {
204 fn call<'reg: 'rc, 'rc>(

Callers

nothing calls this directly

Calls 12

get_param_as_strMethod · 0.80
trim_charMethod · 0.80
trim_start_charMethod · 0.80
trim_end_charMethod · 0.80
get_param_as_integerMethod · 0.80
get_param_as_boolMethod · 0.80
on_one_lineMethod · 0.80

Tested by

no test coverage detected