| 1 | use craterust-analyzer cargo handlebars 5.1.2 crate/::contextrust-analyzer cargo handlebars 5.1.2 context/::Contextrust-analyzer cargo handlebars 5.1.2 context/Context#; |
| 2 | use craterust-analyzer cargo handlebars 5.1.2 crate/::helpersrust-analyzer cargo handlebars 5.1.2 helpers/::{HelperDefrust-analyzer cargo handlebars 5.1.2 helpers/HelperDef#, HelperResultrust-analyzer cargo handlebars 5.1.2 helpers/HelperResult#}; |
| 3 | use craterust-analyzer cargo handlebars 5.1.2 crate/::jsonrust-analyzer cargo handlebars 5.1.2 json/::valuerust-analyzer cargo handlebars 5.1.2 json/value/::JsonTruthyrust-analyzer cargo handlebars 5.1.2 json/value/JsonTruthy#; |
| 4 | use craterust-analyzer cargo handlebars 5.1.2 crate/::outputrust-analyzer cargo handlebars 5.1.2 output/::Outputrust-analyzer cargo handlebars 5.1.2 output/Output#; |
| 5 | use craterust-analyzer cargo handlebars 5.1.2 crate/::registryrust-analyzer cargo handlebars 5.1.2 registry/::Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#; |
| 6 | use craterust-analyzer cargo handlebars 5.1.2 crate/::renderrust-analyzer cargo handlebars 5.1.2 render/::{Helperrust-analyzer cargo handlebars 5.1.2 render/Helper#, RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#, Renderablerust-analyzer cargo handlebars 5.1.2 render/Renderable#}; |
| 7 | use craterust-analyzer cargo handlebars 5.1.2 crate/::RenderErrorReasonrust-analyzer cargo handlebars 5.1.2 error/RenderErrorReason#; |
| 8 | |
| 9 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)] |
| 10 | pub struct IfHelperrust-analyzer cargo handlebars 5.1.2 helpers/helper_if/IfHelper# { |
| 11 | positiverust-analyzer cargo handlebars 5.1.2 helpers/helper_if/IfHelper#positive.: bool, |
| 12 | } |
| 13 | |
| 14 | impl HelperDefrust-analyzer cargo handlebars 5.1.2 helpers/HelperDef# for IfHelperrust-analyzer cargo handlebars 5.1.2 helpers/helper_if/IfHelper# { |
| 15 | fn callrust-analyzer cargo handlebars 5.1.2 helpers/helper_if/impl#[IfHelper][HelperDef]call().<'reg: 'rc, 'rc>( |
| 16 | &self, |
| 17 | h: &Helperrust-analyzer cargo handlebars 5.1.2 render/Helper#<'rc>, |
| 18 | r: &'reg Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 19 | ctx: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 20 | rc: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 21 | out: &mut dyn Outputrust-analyzer cargo handlebars 5.1.2 output/Output#, |
| 22 | ) -> HelperResultrust-analyzer cargo handlebars 5.1.2 helpers/HelperResult# { |
| 23 | let param = h |
| 24 | .paramrust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]param().(0) |
| 25 | .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(RenderErrorReasonrust-analyzer cargo handlebars 5.1.2 error/RenderErrorReason#::ParamNotFoundForIndexrust-analyzer cargo handlebars 5.1.2 error/RenderErrorReason#ParamNotFoundForIndex#("if", 0))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 26 | let include_zero = h |
| 27 | .hash_getrust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]hash_get().("includeZero") |
| 28 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|v| v.valuerust-analyzer cargo handlebars 5.1.2 json/value/impl#[`PathAndJson<'rc>`]value().().as_boolrust-analyzer cargo serde_json 1.0.114 value/impl#[Value]as_bool().()) |
| 29 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false); |
| 30 | |
| 31 | let mut value = param.valuerust-analyzer cargo handlebars 5.1.2 json/value/impl#[`PathAndJson<'rc>`]value().().is_truthyrust-analyzer cargo handlebars 5.1.2 json/value/impl#[Json][JsonTruthy]is_truthy().(include_zero); |
| 32 | |
| 33 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.positiverust-analyzer cargo handlebars 5.1.2 helpers/helper_if/IfHelper#positive. { |
| 34 | value = !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().value; |
| 35 | } |
| 36 | |
| 37 | let tmpl = if value { h.templaterust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]template().() } else { h.inverserust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]inverse().() }; |
| 38 | match tmpl { |
| 39 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(t) => t.renderrust-analyzer cargo handlebars 5.1.2 render/impl#[Template][Renderable]render().(r, ctx, rc, out), |
| 40 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()), |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | pub static IF_HELPERrust-analyzer cargo handlebars 5.1.2 helpers/helper_if/IF_HELPER.: IfHelperrust-analyzer cargo handlebars 5.1.2 helpers/helper_if/IfHelper# = IfHelperrust-analyzer cargo handlebars 5.1.2 helpers/helper_if/IfHelper# { positiverust-analyzer cargo handlebars 5.1.2 helpers/helper_if/IfHelper#positive.: true }; |
| 46 | pub static UNLESS_HELPERrust-analyzer cargo handlebars 5.1.2 helpers/helper_if/UNLESS_HELPER.: IfHelperrust-analyzer cargo handlebars 5.1.2 helpers/helper_if/IfHelper# = IfHelperrust-analyzer cargo handlebars 5.1.2 helpers/helper_if/IfHelper# { positiverust-analyzer cargo handlebars 5.1.2 helpers/helper_if/IfHelper#positive.: false }; |
| 47 | |
| 48 | #[cfg(test)] |
| 49 | mod testrust-analyzer cargo handlebars 5.1.2 helpers/helper_if/test/ { |
| 50 | use craterust-analyzer cargo handlebars 5.1.2 crate/::helpersrust-analyzer cargo handlebars 5.1.2 helpers/::WITH_HELPERrust-analyzer cargo handlebars 5.1.2 helpers/helper_with/WITH_HELPER.; |
| 51 | use craterust-analyzer cargo handlebars 5.1.2 crate/::registryrust-analyzer cargo handlebars 5.1.2 registry/::Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#; |
| 52 | use serde_jsonrust-analyzer cargo serde_json 1.0.114 crate/::valuerust-analyzer cargo serde_json 1.0.114 value/::Valuerust-analyzer cargo serde_json 1.0.114 value/Value# as Jsonrust-analyzer cargo serde_json 1.0.114 value/Value#; |
| 53 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#; |
| 54 | |
| 55 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 56 | fn test_ifrust-analyzer cargo handlebars 5.1.2 helpers/helper_if/test/test_if().() { |
| 57 | let mut handlebars = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 58 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(handlebars |
| 59 | .register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("t0", "{{#if this}}hello{{/if}}") |
| 60 | .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 61 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(handlebars |
| 62 | .register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("t1", "{{#unless this}}hello{{else}}world{{/unless}}") |
| 63 | .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 64 | |
| 65 | let r0 = handlebars.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("t0", &true); |
| 66 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r0.okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "hello".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 67 | |
| 68 | let r1 = handlebars.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("t1", &true); |
| 69 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r1.okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "world".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 70 | |
| 71 | let r2 = handlebars.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("t0", &false); |
| 72 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r2.okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 73 | } |
| 74 | |
| 75 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 76 | fn test_if_contextrust-analyzer cargo handlebars 5.1.2 helpers/helper_if/test/test_if_context().() { |
| 77 | let json_str = r#"{"a":{"b":99,"c":{"d": true}}}"#; |
| 78 | let data = Jsonrust-analyzer cargo serde_json 1.0.114 value/Value#::from_strrust-analyzer cargo serde_json 1.0.114 value/de/impl#[Value][FromStr]from_str().(json_str).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 79 | |
| 80 | let mut handlebars = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 81 | handlebars.register_helperrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_helper().("with", Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(WITH_HELPERrust-analyzer cargo handlebars 5.1.2 helpers/helper_with/WITH_HELPER.)); |
| 82 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(handlebars |
| 83 | .register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("t0", "{{#if a.c.d}}hello {{a.b}}{{/if}}") |
| 84 | .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 85 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(handlebars |
| 86 | .register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().( |
| 87 | "t1", |
| 88 | "{{#with a}}{{#if c.d}}hello {{../a.b}}{{/if}}{{/with}}" |
| 89 | ) |
| 90 | .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 91 | |
| 92 | let r0 = handlebars.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("t0", &data); |
| 93 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r0.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "hello 99".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 94 | |
| 95 | let r1 = handlebars.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("t1", &data); |
| 96 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r1.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "hello 99".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 97 | } |
| 98 | |
| 99 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 100 | fn test_if_else_chainrust-analyzer cargo handlebars 5.1.2 helpers/helper_if/test/test_if_else_chain().() { |
| 101 | let handlebars = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 102 | |
| 103 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 104 | "0".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 105 | handlebars |
| 106 | .render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().("{{#if a}}1{{else if b}}2{{else}}0{{/if}}", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"d": 1})) |
| 107 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 108 | ); |
| 109 | } |
| 110 | |
| 111 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 112 | fn test_if_else_chain2rust-analyzer cargo handlebars 5.1.2 helpers/helper_if/test/test_if_else_chain2().() { |
| 113 | let handlebars = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 114 | |
| 115 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 116 | "3".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 117 | handlebars |
| 118 | .render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().( |
| 119 | "{{#if a}}1{{else if b}}2{{else if c}}3{{else if d}}4{{else}}0{{/if}}", |
| 120 | &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"c": 1, "d":1}) |
| 121 | ) |
| 122 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 123 | ); |
| 124 | } |
| 125 | |
| 126 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 127 | fn test_if_else_chain3rust-analyzer cargo handlebars 5.1.2 helpers/helper_if/test/test_if_else_chain3().() { |
| 128 | let handlebars = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 129 | |
| 130 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 131 | "4".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 132 | handlebars |
| 133 | .render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().( |
| 134 | "{{#if a}}1{{else if b}}2{{else if c}}3{{else if d}}4{{/if}}", |
| 135 | &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"d":1}) |
| 136 | ) |
| 137 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 138 | ); |
| 139 | } |
| 140 | |
| 141 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 142 | fn test_if_else_chain4rust-analyzer cargo handlebars 5.1.2 helpers/helper_if/test/test_if_else_chain4().() { |
| 143 | let handlebars = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 144 | |
| 145 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 146 | "1".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 147 | handlebars |
| 148 | .render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().( |
| 149 | "{{#if a}}1{{else if b}}2{{else if c}}3{{else if d}}4{{/if}}", |
| 150 | &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"a":1}) |
| 151 | ) |
| 152 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 153 | ); |
| 154 | } |
| 155 | |
| 156 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 157 | fn test_if_include_zerorust-analyzer cargo handlebars 5.1.2 helpers/helper_if/test/test_if_include_zero().() { |
| 158 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::f64rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/; |
| 159 | let handlebars = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 160 | |
| 161 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 162 | "0".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 163 | handlebars |
| 164 | .render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().("{{#if a}}1{{else}}0{{/if}}", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"a": 0})) |
| 165 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 166 | ); |
| 167 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 168 | "1".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 169 | handlebars |
| 170 | .render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().( |
| 171 | "{{#if a includeZero=true}}1{{else}}0{{/if}}", |
| 172 | &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"a": 0}) |
| 173 | ) |
| 174 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 175 | ); |
| 176 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 177 | "0".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 178 | handlebars |
| 179 | .render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().( |
| 180 | "{{#if a includeZero=true}}1{{else}}0{{/if}}", |
| 181 | &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({ "a": f64rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/::NANrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/NAN. }) |
| 182 | ) |
| 183 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 184 | ); |
| 185 | } |
| 186 | |
| 187 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 188 | fn test_invisible_line_strippingrust-analyzer cargo handlebars 5.1.2 helpers/helper_if/test/test_invisible_line_stripping().() { |
| 189 | let hbs = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 190 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 191 | "yes\n", |
| 192 | hbs.render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().("{{#if a}}\nyes\n{{/if}}\n", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"a": true})) |
| 193 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 194 | ); |
| 195 | |
| 196 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 197 | "yes\r\n", |
| 198 | hbs.render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().("{{#if a}}\r\nyes\r\n{{/if}}\r\n", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"a": true})) |
| 199 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 200 | ); |
| 201 | |
| 202 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 203 | "x\ny", |
| 204 | hbs.render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().("{{#if a}}x{{/if}}\ny", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"a": true})) |
| 205 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 206 | ); |
| 207 | |
| 208 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 209 | "y\nz", |
| 210 | hbs.render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().("{{#if a}}\nx\n{{^}}\ny\n{{/if}}\nz", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"a": false})) |
| 211 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 212 | ); |
| 213 | |
| 214 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 215 | r#"yes |
| 216 | foo |
| 217 | bar |
| 218 | baz"#, |
| 219 | hbs.render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().( |
| 220 | r#"yes |
| 221 | {{#if true}} |
| 222 | foo |
| 223 | bar |
| 224 | {{/if}} |
| 225 | baz"#, |
| 226 | &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({}) |
| 227 | ) |
| 228 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 229 | ); |
| 230 | |
| 231 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 232 | r#" foo |
| 233 | bar |
| 234 | baz"#, |
| 235 | hbs.render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().( |
| 236 | r#" {{#if true}} |
| 237 | foo |
| 238 | bar |
| 239 | {{/if}} |
| 240 | baz"#, |
| 241 | &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({}) |
| 242 | ) |
| 243 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 244 | ); |
| 245 | } |
| 246 | } |