(
&self,
h: &handlebars::Helper<'rc>,
handle: &'reg handlebars::Handlebars<'reg>,
ctx: &'rc handlebars::Context,
render_ctx: &mut handlebars::RenderContext<'reg, 'rc>,
out: &mu
| 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 | ///``` |
| 201 | pub struct StartWithHelper; |
| 202 | |
| 203 | impl HelperDef for StartWithHelper { |
| 204 | fn call<'reg: 'rc, 'rc>( |
nothing calls this directly
no test coverage detected