| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::{HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#, VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#}; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::Peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/Peekable#; |
| 3 | 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#; |
| 4 | |
| 5 | use pestrust-analyzer cargo pest 2.7.8 crate/::errorrust-analyzer cargo pest 2.7.8 error/::LineColLocationrust-analyzer cargo pest 2.7.8 error/LineColLocation#; |
| 6 | use pestrust-analyzer cargo pest 2.7.8 crate/::iteratorsrust-analyzer cargo pest 2.7.8 iterators/::Pairrust-analyzer cargo pest 2.7.8 iterators/pair/Pair#; |
| 7 | use pestrust-analyzer cargo pest 2.7.8 crate/::{Parserrust-analyzer cargo pest 2.7.8 parser/Parser#, Positionrust-analyzer cargo pest 2.7.8 position/Position#, Spanrust-analyzer cargo pest 2.7.8 span/Span#}; |
| 8 | 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#; |
| 9 | |
| 10 | use craterust-analyzer cargo handlebars 5.1.2 crate/::errorrust-analyzer cargo handlebars 5.1.2 error/::{TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#, TemplateErrorReasonrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#}; |
| 11 | use craterust-analyzer cargo handlebars 5.1.2 crate/::grammarrust-analyzer cargo handlebars 5.1.2 grammar/::{HandlebarsParserrust-analyzer cargo handlebars 5.1.2 grammar/HandlebarsParser#, Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#}; |
| 12 | use craterust-analyzer cargo handlebars 5.1.2 crate/::jsonrust-analyzer cargo handlebars 5.1.2 json/::pathrust-analyzer cargo handlebars 5.1.2 json/path/::{parse_json_path_from_iterrust-analyzer cargo handlebars 5.1.2 json/path/parse_json_path_from_iter()., Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#}; |
| 13 | use craterust-analyzer cargo handlebars 5.1.2 crate/::supportrust-analyzer cargo handlebars 5.1.2 support/; |
| 14 | |
| 15 | use selfrust-analyzer cargo handlebars 5.1.2 template/::TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#::*; |
| 16 | |
| 17 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 18 | pub struct TemplateMappingrust-analyzer cargo handlebars 5.1.2 template/TemplateMapping#(pub usize, pub usize); |
| 19 | |
| 20 | /// A handlebars template |
| 21 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 22 | pub struct Templaterust-analyzer cargo handlebars 5.1.2 template/Template# { |
| 23 | pub namerust-analyzer cargo handlebars 5.1.2 template/Template#name.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 24 | pub elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#>, |
| 25 | pub mappingrust-analyzer cargo handlebars 5.1.2 template/Template#mapping.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<TemplateMappingrust-analyzer cargo handlebars 5.1.2 template/TemplateMapping#>, |
| 26 | } |
| 27 | |
| 28 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 29 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) struct TemplateOptionsrust-analyzer cargo handlebars 5.1.2 template/TemplateOptions# { |
| 30 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) prevent_indentrust-analyzer cargo handlebars 5.1.2 template/TemplateOptions#prevent_indent.: bool, |
| 31 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) namerust-analyzer cargo handlebars 5.1.2 template/TemplateOptions#name.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 32 | } |
| 33 | |
| 34 | impl TemplateOptionsrust-analyzer cargo handlebars 5.1.2 template/TemplateOptions# { |
| 35 | fn namerust-analyzer cargo handlebars 5.1.2 template/impl#[TemplateOptions]name().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 36 | self.namerust-analyzer cargo handlebars 5.1.2 template/TemplateOptions#name. |
| 37 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 38 | .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]cloned().() |
| 39 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| "Unnamed".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 44 | pub struct Subexpressionrust-analyzer cargo handlebars 5.1.2 template/Subexpression# { |
| 45 | // we use box here avoid resursive struct definition |
| 46 | pub elementrust-analyzer cargo handlebars 5.1.2 template/Subexpression#element.: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#>, |
| 47 | } |
| 48 | |
| 49 | impl Subexpressionrust-analyzer cargo handlebars 5.1.2 template/Subexpression# { |
| 50 | pub fn newrust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]new().( |
| 51 | name: Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#, |
| 52 | params: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#>, |
| 53 | hash: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#>, |
| 54 | ) -> Subexpressionrust-analyzer cargo handlebars 5.1.2 template/Subexpression# { |
| 55 | Subexpressionrust-analyzer cargo handlebars 5.1.2 template/Subexpression# { |
| 56 | elementrust-analyzer cargo handlebars 5.1.2 template/Subexpression#element.: 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().(Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(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().(HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate# { |
| 57 | namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name., |
| 58 | paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params., |
| 59 | hashrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#hash., |
| 60 | templaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#template.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 61 | inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 62 | block_paramrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block_param.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 63 | blockrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block.: false, |
| 64 | chainrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#chain.: false, |
| 65 | }))), |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | pub fn is_helperrust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]is_helper().(&self) -> bool { |
| 70 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self.as_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]as_element().() { |
| 71 | TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#::Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(ref ht) => !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().ht.is_name_onlyrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]is_name_only().(), |
| 72 | _ => false, |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | pub fn as_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]as_element().(&self) -> &TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement# { |
| 77 | self.elementrust-analyzer cargo handlebars 5.1.2 template/Subexpression#element..as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][`AsRef<T>`]as_ref().() |
| 78 | } |
| 79 | |
| 80 | pub fn namerust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]name().(&self) -> &str { |
| 81 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self.as_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]as_element().() { |
| 82 | // FIXME: avoid unwrap here |
| 83 | Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(ref ht) => ht.namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name..as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 84 | _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | pub fn paramsrust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]params().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#>> { |
| 89 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self.as_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]as_element().() { |
| 90 | Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(ref ht) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&ht.paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params.), |
| 91 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | pub fn hashrust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]hash().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#>> { |
| 96 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self.as_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]as_element().() { |
| 97 | Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(ref ht) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&ht.hashrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#hash.), |
| 98 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 104 | pub enum BlockParamrust-analyzer cargo handlebars 5.1.2 template/BlockParam# { |
| 105 | Singlerust-analyzer cargo handlebars 5.1.2 template/BlockParam#Single#(Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#), |
| 106 | Pairrust-analyzer cargo handlebars 5.1.2 template/BlockParam#Pair#((Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#, Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#)), |
| 107 | } |
| 108 | |
| 109 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 110 | pub struct ExpressionSpecrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec# { |
| 111 | pub namerust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#name.: Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#, |
| 112 | pub paramsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#params.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#>, |
| 113 | pub hashrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#hash.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#>, |
| 114 | pub block_paramrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#block_param.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<BlockParamrust-analyzer cargo handlebars 5.1.2 template/BlockParam#>, |
| 115 | pub omit_pre_wsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#omit_pre_ws.: bool, |
| 116 | pub omit_pro_wsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#omit_pro_ws.: bool, |
| 117 | } |
| 118 | |
| 119 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 120 | pub enum Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter# { |
| 121 | // for helper name only |
| 122 | Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#), |
| 123 | // for expression, helper param and hash |
| 124 | Pathrust-analyzer cargo handlebars 5.1.2 template/Parameter#Path#(Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#), |
| 125 | Literalrust-analyzer cargo handlebars 5.1.2 template/Parameter#Literal#(Jsonrust-analyzer cargo serde_json 1.0.114 value/Value#), |
| 126 | Subexpressionrust-analyzer cargo handlebars 5.1.2 template/Parameter#Subexpression#(Subexpressionrust-analyzer cargo handlebars 5.1.2 template/Subexpression#), |
| 127 | } |
| 128 | |
| 129 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 130 | pub struct HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate# { |
| 131 | pub namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name.: Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#, |
| 132 | pub paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#>, |
| 133 | pub hashrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#hash.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#>, |
| 134 | pub block_paramrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block_param.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<BlockParamrust-analyzer cargo handlebars 5.1.2 template/BlockParam#>, |
| 135 | pub templaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#template.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Templaterust-analyzer cargo handlebars 5.1.2 template/Template#>, |
| 136 | pub inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Templaterust-analyzer cargo handlebars 5.1.2 template/Template#>, |
| 137 | pub blockrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block.: bool, |
| 138 | pub chainrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#chain.: bool, |
| 139 | } |
| 140 | |
| 141 | impl HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate# { |
| 142 | pub fn newrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]new().(exp: ExpressionSpecrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#, block: bool) -> HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate# { |
| 143 | HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate# { |
| 144 | namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name.: exp.namerust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#name., |
| 145 | paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params.: exp.paramsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#params., |
| 146 | hashrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#hash.: exp.hashrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#hash., |
| 147 | block_paramrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block_param.: exp.block_paramrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#block_param., |
| 148 | blockrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block., |
| 149 | templaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#template.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 150 | inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 151 | chainrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#chain.: false, |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | pub fn new_chainrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]new_chain().(exp: ExpressionSpecrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#, block: bool) -> HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate# { |
| 156 | HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate# { |
| 157 | namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name.: exp.namerust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#name., |
| 158 | paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params.: exp.paramsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#params., |
| 159 | hashrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#hash.: exp.hashrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#hash., |
| 160 | block_paramrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block_param.: exp.block_paramrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#block_param., |
| 161 | blockrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block., |
| 162 | templaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#template.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 163 | inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 164 | chainrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#chain.: true, |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | // test only |
| 169 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) fn with_pathrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]with_path().(path: Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#) -> HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate# { |
| 170 | HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate# { |
| 171 | namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name.: Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Pathrust-analyzer cargo handlebars 5.1.2 template/Parameter#Path#(path), |
| 172 | paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(5), |
| 173 | hashrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#hash.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(), |
| 174 | block_paramrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block_param.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 175 | templaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#template.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 176 | inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 177 | blockrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block.: false, |
| 178 | chainrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#chain.: false, |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) fn is_name_onlyrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]is_name_only().(&self) -> bool { |
| 183 | !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.blockrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block. && self.paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() && self.hashrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#hash..is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]is_empty().() |
| 184 | } |
| 185 | |
| 186 | fn insert_inverse_noderust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]insert_inverse_node().(&mut self, mut node: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#>) { |
| 187 | // Create a list in "inverse" member to hold the else-chain. |
| 188 | // Here we create the new template to save the else-chain node. |
| 189 | // The template render could render it successfully without any code add. |
| 190 | let mut new_chain_template = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::newrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]new().(); |
| 191 | node.inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse. = self.inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().(); |
| 192 | new_chain_template.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HelperBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HelperBlock#(node)); |
| 193 | self.inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(new_chain_template); |
| 194 | } |
| 195 | |
| 196 | fn ref_chain_head_mutrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]ref_chain_head_mut().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#>> { |
| 197 | if self.chainrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#chain. { |
| 198 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(inverse_tmpl) = &mut self.inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse. { |
| 199 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(inverse_tmpl.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 200 | if let HelperBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HelperBlock#(helper) = &mut inverse_tmpl.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). { |
| 201 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(helper); |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 206 | } |
| 207 | |
| 208 | fn set_chain_templaterust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]set_chain_template().(&mut self, tmpl: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Templaterust-analyzer cargo handlebars 5.1.2 template/Template#>) { |
| 209 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(hepler) = self.ref_chain_head_mutrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]ref_chain_head_mut().() { |
| 210 | hepler.templaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#template. = tmpl; |
| 211 | } else { |
| 212 | self.templaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#template. = tmpl; |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | fn revert_chain_and_setrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]revert_chain_and_set().(&mut self, inverse: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Templaterust-analyzer cargo handlebars 5.1.2 template/Template#>) { |
| 217 | if self.chainrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#chain. { |
| 218 | let mut prev = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 219 | |
| 220 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(head) = self.ref_chain_head_mutrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]ref_chain_head_mut().() { |
| 221 | if head.templaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#template..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 222 | // Here the prev will hold the head inverse template. |
| 223 | // It will be set when reverse the chain. |
| 224 | prev = inverse; |
| 225 | } else { |
| 226 | // If the head already has template. set the inverse template. |
| 227 | head.templaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#template. = inverse; |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | // Reverse the else chain, to the normal list order. |
| 232 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mut node) = self.inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() { |
| 233 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(node.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 234 | if let HelperBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HelperBlock#(c) = &mut node.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). { |
| 235 | self.inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse. = c.inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().(); |
| 236 | c.inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse. = prev; |
| 237 | prev = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(node); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | self.inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse. = prev; |
| 242 | } else { |
| 243 | // If the helper has no else chain. |
| 244 | // set the template to self. |
| 245 | if self.templaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#template..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 246 | self.inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse. = inverse; |
| 247 | } else { |
| 248 | self.templaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#template. = inverse; |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | fn set_chainedrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]set_chained().(&mut self) { |
| 254 | self.chainrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#chain. = true; |
| 255 | } |
| 256 | |
| 257 | pub fn is_chainedrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]is_chained().(&self) -> bool { |
| 258 | self.chainrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#chain. |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 263 | pub struct DecoratorTemplaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate# { |
| 264 | pub namerust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#name.: Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#, |
| 265 | pub paramsrust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#params.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#>, |
| 266 | pub hashrust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#hash.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#>, |
| 267 | pub templaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#template.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Templaterust-analyzer cargo handlebars 5.1.2 template/Template#>, |
| 268 | // for partial indent |
| 269 | pub indentrust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#indent.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 270 | } |
| 271 | |
| 272 | impl DecoratorTemplaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate# { |
| 273 | pub fn newrust-analyzer cargo handlebars 5.1.2 template/impl#[DecoratorTemplate]new().(exp: ExpressionSpecrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#) -> DecoratorTemplaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate# { |
| 274 | DecoratorTemplaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate# { |
| 275 | namerust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#name.: exp.namerust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#name., |
| 276 | paramsrust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#params.: exp.paramsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#params., |
| 277 | hashrust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#hash.: exp.hashrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#hash., |
| 278 | templaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#template.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 279 | indentrust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#indent.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | impl Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter# { |
| 285 | pub fn as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> { |
| 286 | match self { |
| 287 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#(ref n) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(n), |
| 288 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Pathrust-analyzer cargo handlebars 5.1.2 template/Parameter#Path#(ref p) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(p.rawrust-analyzer cargo handlebars 5.1.2 json/path/impl#[Path]raw().()), |
| 289 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | pub fn parserust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]parse().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#, TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#> { |
| 294 | let parser = HandlebarsParserrust-analyzer cargo handlebars 5.1.2 grammar/HandlebarsParser#::parserust-analyzer cargo handlebars 5.1.2 grammar/impl#[HandlebarsParser][`Parser<Rule>`]parse().(Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::parameterrust-analyzer cargo handlebars 5.1.2 grammar/Rule#parameter#, s) |
| 295 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#::ofrust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]of().(TemplateErrorReasonrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#::InvalidParamrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#InvalidParam#(s.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 296 | |
| 297 | let mut it = parser.flattenrust-analyzer cargo pest 2.7.8 iterators/pairs/impl#[`Pairs<'i, R>`]flatten().().peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#peekable().(); |
| 298 | Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::parse_paramrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_param().(s, &mut it, s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1) |
| 299 | } |
| 300 | |
| 301 | fn debug_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]debug_name().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 302 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(name) = self.as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().() { |
| 303 | name.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() |
| 304 | } else { |
| 305 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{self:?}") |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | |
| 310 | impl Templaterust-analyzer cargo handlebars 5.1.2 template/Template# { |
| 311 | pub fn newrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]new().() -> Templaterust-analyzer cargo handlebars 5.1.2 template/Template# { |
| 312 | Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::defaultrust-analyzer cargo handlebars 5.1.2 template/impl#[Template][Default]default().() |
| 313 | } |
| 314 | |
| 315 | fn push_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]push_element().(&mut self, e: TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#, line: usize, col: usize) { |
| 316 | self.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(e); |
| 317 | self.mappingrust-analyzer cargo handlebars 5.1.2 template/Template#mapping..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(TemplateMappingrust-analyzer cargo handlebars 5.1.2 template/TemplateMapping#(line, col)); |
| 318 | } |
| 319 | |
| 320 | fn parse_subexpressionrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_subexpression().<'a, I>( |
| 321 | source: &'a str, |
| 322 | it: &mut Peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/Peekable#<I>, |
| 323 | limit: usize, |
| 324 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#, TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#> |
| 325 | where |
| 326 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Pairrust-analyzer cargo pest 2.7.8 iterators/pair/Pair#<'a, Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#>>, |
| 327 | { |
| 328 | let espec = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::parse_expressionrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_expression().(source, it.by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().(), limit)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 329 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Subexpressionrust-analyzer cargo handlebars 5.1.2 template/Parameter#Subexpression#(Subexpressionrust-analyzer cargo handlebars 5.1.2 template/Subexpression#::newrust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]new().( |
| 330 | espec.namerust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#name., |
| 331 | espec.paramsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#params., |
| 332 | espec.hashrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#hash., |
| 333 | ))) |
| 334 | } |
| 335 | |
| 336 | fn parse_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_name().<'a, I>( |
| 337 | source: &'a str, |
| 338 | it: &mut Peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/Peekable#<I>, |
| 339 | _: usize, |
| 340 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#, TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#> |
| 341 | where |
| 342 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Pairrust-analyzer cargo pest 2.7.8 iterators/pair/Pair#<'a, Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#>>, |
| 343 | { |
| 344 | let name_node = it.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 345 | let rule = name_node.as_rulerust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_rule().(); |
| 346 | let name_span = name_node.as_spanrust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_span().(); |
| 347 | match rule { |
| 348 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::identifierrust-analyzer cargo handlebars 5.1.2 grammar/Rule#identifier# | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::partial_identifierrust-analyzer cargo handlebars 5.1.2 grammar/Rule#partial_identifier# | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::invert_tag_itemrust-analyzer cargo handlebars 5.1.2 grammar/Rule#invert_tag_item# => { |
| 349 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#(name_span.as_strrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]as_str().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())) |
| 350 | } |
| 351 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::referencerust-analyzer cargo handlebars 5.1.2 grammar/Rule#reference# => { |
| 352 | let paths = parse_json_path_from_iterrust-analyzer cargo handlebars 5.1.2 json/path/parse_json_path_from_iter().(it, name_span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().()); |
| 353 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Pathrust-analyzer cargo handlebars 5.1.2 template/Parameter#Path#(Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#::newrust-analyzer cargo handlebars 5.1.2 json/path/impl#[Path]new().(name_span.as_strrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]as_str().(), paths))) |
| 354 | } |
| 355 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::subexpressionrust-analyzer cargo handlebars 5.1.2 grammar/Rule#subexpression# => { |
| 356 | Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::parse_subexpressionrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_subexpression().(source, it.by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().(), name_span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().()) |
| 357 | } |
| 358 | _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | fn parse_paramrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_param().<'a, I>( |
| 363 | source: &'a str, |
| 364 | it: &mut Peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/Peekable#<I>, |
| 365 | _: usize, |
| 366 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#, TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#> |
| 367 | where |
| 368 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Pairrust-analyzer cargo pest 2.7.8 iterators/pair/Pair#<'a, Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#>>, |
| 369 | { |
| 370 | let mut param = it.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 371 | if param.as_rulerust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_rule().() rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().==rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq(). rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::helper_parameterrust-analyzer cargo handlebars 5.1.2 grammar/Rule#helper_parameter# { |
| 372 | param = it.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 373 | } |
| 374 | let param_rule = param.as_rulerust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_rule().(); |
| 375 | let param_span = param.as_spanrust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_span().(); |
| 376 | let result = match param_rule { |
| 377 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::referencerust-analyzer cargo handlebars 5.1.2 grammar/Rule#reference# => { |
| 378 | let path_segs = parse_json_path_from_iterrust-analyzer cargo handlebars 5.1.2 json/path/parse_json_path_from_iter().(it, param_span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().()); |
| 379 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Pathrust-analyzer cargo handlebars 5.1.2 template/Parameter#Path#(Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#::newrust-analyzer cargo handlebars 5.1.2 json/path/impl#[Path]new().(param_span.as_strrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]as_str().(), path_segs)) |
| 380 | } |
| 381 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::literalrust-analyzer cargo handlebars 5.1.2 grammar/Rule#literal# => { |
| 382 | // Parse the parameter as a JSON literal |
| 383 | let param_literal = it.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 384 | let json_result = match param_literal.as_rulerust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_rule().() { |
| 385 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::string_literalrust-analyzer cargo handlebars 5.1.2 grammar/Rule#string_literal# |
| 386 | if it.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().as_rulerust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_rule().() rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().==rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq(). rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::string_inner_single_quoterust-analyzer cargo handlebars 5.1.2 grammar/Rule#string_inner_single_quote# => |
| 387 | { |
| 388 | // ...unless the parameter is a single-quoted string. |
| 389 | // In that case, transform it to a double-quoted string |
| 390 | // and then parse it as a JSON literal. |
| 391 | let string_inner_single_quote = it.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 392 | let double_quoted = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 393 | "\"{}\"", |
| 394 | string_inner_single_quote |
| 395 | .as_strrust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_str().() |
| 396 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().("\\'", "'") |
| 397 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('"', "\\\"") |
| 398 | ); |
| 399 | 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().(&double_quoted) |
| 400 | } |
| 401 | _ => 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().(param_span.as_strrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]as_str().()), |
| 402 | }; |
| 403 | if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(json) = json_result { |
| 404 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Literalrust-analyzer cargo handlebars 5.1.2 template/Parameter#Literal#(json) |
| 405 | } else { |
| 406 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#::ofrust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]of().(TemplateErrorReasonrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#::InvalidParamrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#InvalidParam#( |
| 407 | param_span.as_strrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]as_str().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 408 | ))); |
| 409 | } |
| 410 | } |
| 411 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::subexpressionrust-analyzer cargo handlebars 5.1.2 grammar/Rule#subexpression# => { |
| 412 | Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::parse_subexpressionrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_subexpression().(source, it.by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().(), param_span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 413 | } |
| 414 | _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 415 | }; |
| 416 | |
| 417 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(n) = it.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().() { |
| 418 | let n_span = n.as_spanrust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_span().(); |
| 419 | if n_span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().param_span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().() { |
| 420 | break; |
| 421 | } |
| 422 | it.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().(); |
| 423 | } |
| 424 | |
| 425 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(result) |
| 426 | } |
| 427 | |
| 428 | fn parse_hashrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_hash().<'a, I>( |
| 429 | source: &'a str, |
| 430 | it: &mut Peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/Peekable#<I>, |
| 431 | limit: usize, |
| 432 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#), TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#> |
| 433 | where |
| 434 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Pairrust-analyzer cargo pest 2.7.8 iterators/pair/Pair#<'a, Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#>>, |
| 435 | { |
| 436 | let name = it.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 437 | let name_node = name.as_spanrust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_span().(); |
| 438 | // identifier |
| 439 | let key = name_node.as_strrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]as_str().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(); |
| 440 | |
| 441 | let value = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::parse_paramrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_param().(source, it.by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().(), limit)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 442 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((key, value)) |
| 443 | } |
| 444 | |
| 445 | fn parse_block_paramrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_block_param().<'a, I>(_: &'a str, it: &mut Peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/Peekable#<I>, limit: usize) -> BlockParamrust-analyzer cargo handlebars 5.1.2 template/BlockParam# |
| 446 | where |
| 447 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Pairrust-analyzer cargo pest 2.7.8 iterators/pair/Pair#<'a, Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#>>, |
| 448 | { |
| 449 | let p1_name = it.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 450 | let p1_name_span = p1_name.as_spanrust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_span().(); |
| 451 | // identifier |
| 452 | let p1 = p1_name_span.as_strrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]as_str().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(); |
| 453 | |
| 454 | let p2 = it.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|p2_name| { |
| 455 | let p2_name_span = p2_name.as_spanrust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_span().(); |
| 456 | if p2_name_span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().limit { |
| 457 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(p2_name_span.as_strrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]as_str().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()) |
| 458 | } else { |
| 459 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 460 | } |
| 461 | }); |
| 462 | |
| 463 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(p2) = p2 { |
| 464 | it.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().(); |
| 465 | BlockParamrust-analyzer cargo handlebars 5.1.2 template/BlockParam#::Pairrust-analyzer cargo handlebars 5.1.2 template/BlockParam#Pair#((Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#(p1), Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#(p2))) |
| 466 | } else { |
| 467 | BlockParamrust-analyzer cargo handlebars 5.1.2 template/BlockParam#::Singlerust-analyzer cargo handlebars 5.1.2 template/BlockParam#Single#(Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#(p1)) |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | fn parse_expressionrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_expression().<'a, I>( |
| 472 | source: &'a str, |
| 473 | it: &mut Peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/Peekable#<I>, |
| 474 | limit: usize, |
| 475 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<ExpressionSpecrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#, TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#> |
| 476 | where |
| 477 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Pairrust-analyzer cargo pest 2.7.8 iterators/pair/Pair#<'a, Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#>>, |
| 478 | { |
| 479 | let mut params: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 480 | let mut hashes: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#> = HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(); |
| 481 | let mut omit_pre_ws = false; |
| 482 | let mut omit_pro_ws = false; |
| 483 | let mut block_param = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 484 | |
| 485 | if it.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().as_rulerust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_rule().() rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().==rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq(). rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::leading_tilde_to_omit_whitespacerust-analyzer cargo handlebars 5.1.2 grammar/Rule#leading_tilde_to_omit_whitespace# { |
| 486 | omit_pre_ws = true; |
| 487 | it.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().(); |
| 488 | } |
| 489 | |
| 490 | let name = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::parse_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_name().(source, it.by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().(), limit)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 491 | |
| 492 | loop { |
| 493 | let rule; |
| 494 | let end; |
| 495 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pair) = it.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().() { |
| 496 | let pair_span = pair.as_spanrust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_span().(); |
| 497 | if pair_span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().limit { |
| 498 | rule = pair.as_rulerust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_rule().(); |
| 499 | end = pair_span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().(); |
| 500 | } else { |
| 501 | break; |
| 502 | } |
| 503 | } else { |
| 504 | break; |
| 505 | } |
| 506 | |
| 507 | it.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().(); |
| 508 | |
| 509 | match rule { |
| 510 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::helper_parameterrust-analyzer cargo handlebars 5.1.2 grammar/Rule#helper_parameter# => { |
| 511 | params.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::parse_paramrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_param().(source, it.by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().(), end)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); |
| 512 | } |
| 513 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::hashrust-analyzer cargo handlebars 5.1.2 grammar/Rule#hash# => { |
| 514 | let (key, value) = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::parse_hashrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_hash().(source, it.by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().(), end)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 515 | hashes.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(key, value); |
| 516 | } |
| 517 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::block_paramrust-analyzer cargo handlebars 5.1.2 grammar/Rule#block_param# => { |
| 518 | block_param = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::parse_block_paramrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_block_param().(source, it.by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().(), end)); |
| 519 | } |
| 520 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::trailing_tilde_to_omit_whitespacerust-analyzer cargo handlebars 5.1.2 grammar/Rule#trailing_tilde_to_omit_whitespace# => { |
| 521 | omit_pro_ws = true; |
| 522 | } |
| 523 | _ => {} |
| 524 | } |
| 525 | } |
| 526 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ExpressionSpecrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec# { |
| 527 | namerust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#name., |
| 528 | paramsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#params., |
| 529 | hashrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#hash.: hashes, |
| 530 | block_paramrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#block_param., |
| 531 | omit_pre_wsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#omit_pre_ws., |
| 532 | omit_pro_wsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#omit_pro_ws., |
| 533 | }) |
| 534 | } |
| 535 | |
| 536 | fn remove_previous_whitespacerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]remove_previous_whitespace().(template_stack: &mut VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<Templaterust-analyzer cargo handlebars 5.1.2 template/Template#>) { |
| 537 | let t = template_stack.front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 538 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#(ref mut text)) = t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..last_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_mut().() { |
| 539 | text.trim_endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_end().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().().clone_intorust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[T][ToOwned]clone_into().(text); |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | // in handlebars, the whitespaces around statement are |
| 544 | // automatically trimed. |
| 545 | // this function checks if current span has both leading and |
| 546 | // trailing whitespaces, which we treat as a standalone statement. |
| 547 | // |
| 548 | // |
| 549 | fn process_standalone_statementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]process_standalone_statement().( |
| 550 | template_stack: &mut VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<Templaterust-analyzer cargo handlebars 5.1.2 template/Template#>, |
| 551 | source: &str, |
| 552 | current_span: &Spanrust-analyzer cargo pest 2.7.8 span/Span#<'_>, |
| 553 | prevent_indent: bool, |
| 554 | ) -> bool { |
| 555 | let with_trailing_newline = |
| 556 | supportrust-analyzer cargo handlebars 5.1.2 support/::strrust-analyzer cargo handlebars 5.1.2 support/str/::starts_with_empty_linerust-analyzer cargo handlebars 5.1.2 support/str/starts_with_empty_line().(&source[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().current_span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().()..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 557 | |
| 558 | if with_trailing_newline { |
| 559 | let with_leading_newline = |
| 560 | supportrust-analyzer cargo handlebars 5.1.2 support/::strrust-analyzer cargo handlebars 5.1.2 support/str/::ends_with_empty_linerust-analyzer cargo handlebars 5.1.2 support/str/ends_with_empty_line().(&source[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#current_span.startrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]start().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 561 | |
| 562 | // prevent_indent: a special toggle for partial expression |
| 563 | // (>) that leading whitespaces are kept |
| 564 | if prevent_indent && with_leading_newline { |
| 565 | let t = template_stack.front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 566 | // check the last element before current |
| 567 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#(ref mut text)) = t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..last_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_mut().() { |
| 568 | // trim leading space for standalone statement |
| 569 | text.trim_end_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_end_matches().(supportrust-analyzer cargo handlebars 5.1.2 support/::strrust-analyzer cargo handlebars 5.1.2 support/str/::whitespace_matcherrust-analyzer cargo handlebars 5.1.2 support/str/whitespace_matcher().) |
| 570 | .to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() |
| 571 | .clone_intorust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[T][ToOwned]clone_into().(text); |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | // return true when the item is the first element in root template |
| 576 | current_span.startrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]start().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 || with_leading_newline |
| 577 | } else { |
| 578 | false |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | fn raw_stringrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]raw_string().<'a>( |
| 583 | source: &'a str, |
| 584 | pair: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Pairrust-analyzer cargo pest 2.7.8 iterators/pair/Pair#<'a, Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#>>, |
| 585 | trim_start: bool, |
| 586 | trim_start_line: bool, |
| 587 | ) -> TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement# { |
| 588 | let mut s = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().(source); |
| 589 | |
| 590 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pair) = pair { |
| 591 | // the source may contains leading space because of pest's limitation |
| 592 | // we calculate none space start here in order to correct the offset |
| 593 | let pair_span = pair.as_spanrust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_span().(); |
| 594 | |
| 595 | let current_start = pair_span.startrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]start().(); |
| 596 | let span_length = pair_span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().current_start; |
| 597 | let leading_space_offset = s.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().span_length; |
| 598 | |
| 599 | // we would like to iterate pair reversely in order to remove certain |
| 600 | // index from our string buffer so here we convert the inner pairs to |
| 601 | // a vector. |
| 602 | for sub_pair in pair.into_innerrust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]into_inner().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() { |
| 603 | // remove escaped backslash |
| 604 | if sub_pair.as_rulerust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_rule().() rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().==rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq(). rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::escaperust-analyzer cargo handlebars 5.1.2 grammar/Rule#escape# { |
| 605 | let escape_span = sub_pair.as_spanrust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_span().(); |
| 606 | |
| 607 | let backslash_pos = escape_span.startrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]start().(); |
| 608 | let backslash_rel_pos = leading_space_offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().backslash_pos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().current_start; |
| 609 | s.removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]remove().(backslash_rel_pos); |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | if trim_start { |
| 615 | RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#(s.trim_startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()) |
| 616 | } else if trim_start_line { |
| 617 | let s = s.trim_start_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start_matches().(supportrust-analyzer cargo handlebars 5.1.2 support/::strrust-analyzer cargo handlebars 5.1.2 support/str/::whitespace_matcherrust-analyzer cargo handlebars 5.1.2 support/str/whitespace_matcher().); |
| 618 | RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#(supportrust-analyzer cargo handlebars 5.1.2 support/::strrust-analyzer cargo handlebars 5.1.2 support/str/::strip_first_newlinerust-analyzer cargo handlebars 5.1.2 support/str/strip_first_newline().(s).to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()) |
| 619 | } else { |
| 620 | RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#(s) |
| 621 | } |
| 622 | } |
| 623 | |
| 624 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) fn compile2rust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile2().( |
| 625 | source: &str, |
| 626 | options: TemplateOptionsrust-analyzer cargo handlebars 5.1.2 template/TemplateOptions#, |
| 627 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Templaterust-analyzer cargo handlebars 5.1.2 template/Template#, TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#> { |
| 628 | let mut helper_stack: VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#> = VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T>`]new().(); |
| 629 | let mut decorator_stack: VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<DecoratorTemplaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#> = VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T>`]new().(); |
| 630 | let mut template_stack: VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<Templaterust-analyzer cargo handlebars 5.1.2 template/Template#> = VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T>`]new().(); |
| 631 | |
| 632 | let mut omit_pro_ws = false; |
| 633 | // flag for newline removal of standalone statements |
| 634 | // this option is marked as true when standalone statement is detected |
| 635 | // then the leading whitespaces and newline of next rawstring will be trimed |
| 636 | let mut trim_line_required = false; |
| 637 | |
| 638 | let parser_queue = HandlebarsParserrust-analyzer cargo handlebars 5.1.2 grammar/HandlebarsParser#::parserust-analyzer cargo handlebars 5.1.2 grammar/impl#[HandlebarsParser][`Parser<Rule>`]parse().(Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::handlebarsrust-analyzer cargo handlebars 5.1.2 grammar/Rule#handlebars#, source).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| { |
| 639 | let (line_no, col_no) = match e.line_colrust-analyzer cargo pest 2.7.8 error/Error#line_col. { |
| 640 | LineColLocationrust-analyzer cargo pest 2.7.8 error/LineColLocation#::Posrust-analyzer cargo pest 2.7.8 error/LineColLocation#Pos#(line_col) => line_col, |
| 641 | LineColLocationrust-analyzer cargo pest 2.7.8 error/LineColLocation#::Spanrust-analyzer cargo pest 2.7.8 error/LineColLocation#Span#(line_col, _) => line_col, |
| 642 | }; |
| 643 | TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#::ofrust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]of().(TemplateErrorReasonrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#::InvalidSyntaxrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#InvalidSyntax#( |
| 644 | e.variantrust-analyzer cargo pest 2.7.8 error/Error#variant..messagerust-analyzer cargo pest 2.7.8 error/impl#[`ErrorVariant<R>`]message().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 645 | )) |
| 646 | .atrust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]at().(source, line_no, col_no) |
| 647 | .in_templaterust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]in_template().(options.namerust-analyzer cargo handlebars 5.1.2 template/impl#[TemplateOptions]name().()) |
| 648 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 649 | |
| 650 | // dbg!(parser_queue.clone().flatten()); |
| 651 | |
| 652 | // remove escape from our pair queue |
| 653 | let mut it = parser_queue |
| 654 | .flattenrust-analyzer cargo pest 2.7.8 iterators/pairs/impl#[`Pairs<'i, R>`]flatten().() |
| 655 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|p| { |
| 656 | // remove rules that should be silent but not for now due to pest limitation |
| 657 | !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(p.as_rulerust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_rule().(), Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::escaperust-analyzer cargo handlebars 5.1.2 grammar/Rule#escape#) |
| 658 | }) |
| 659 | .peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#peekable().(); |
| 660 | let mut end_pos: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Positionrust-analyzer cargo pest 2.7.8 position/Position#<'_>> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 661 | loop { |
| 662 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pair) = it.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().() { |
| 663 | let prev_end = end_pos.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|p| p.posrust-analyzer cargo pest 2.7.8 position/impl#[`Position<'i>`]pos().()).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0); |
| 664 | let rule = pair.as_rulerust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_rule().(); |
| 665 | let span = pair.as_spanrust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`]as_span().(); |
| 666 | |
| 667 | let is_trailing_string = rule rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::templaterust-analyzer cargo handlebars 5.1.2 grammar/Rule#template# |
| 668 | && span.startrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]start().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().prev_end |
| 669 | && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().omit_pro_ws |
| 670 | && rule rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::raw_textrust-analyzer cargo handlebars 5.1.2 grammar/Rule#raw_text# |
| 671 | && rule rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::raw_block_textrust-analyzer cargo handlebars 5.1.2 grammar/Rule#raw_block_text#; |
| 672 | |
| 673 | if is_trailing_string { |
| 674 | // trailing string check |
| 675 | let (line_no, col_no) = span.start_posrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]start_pos().().line_colrust-analyzer cargo pest 2.7.8 position/impl#[`Position<'i>`]line_col().(); |
| 676 | if rule rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().==rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq(). rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::raw_block_endrust-analyzer cargo handlebars 5.1.2 grammar/Rule#raw_block_end# { |
| 677 | let mut t = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::newrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]new().(); |
| 678 | t.push_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]push_element().( |
| 679 | Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::raw_stringrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]raw_string().( |
| 680 | &source[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().prev_end..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#span.startrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]start().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., |
| 681 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 682 | false, |
| 683 | trim_line_required, |
| 684 | ), |
| 685 | line_no, |
| 686 | col_no, |
| 687 | ); |
| 688 | template_stack.push_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_front().(t); |
| 689 | } else { |
| 690 | let t = template_stack.front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 691 | t.push_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]push_element().( |
| 692 | Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::raw_stringrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]raw_string().( |
| 693 | &source[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().prev_end..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#span.startrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]start().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., |
| 694 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 695 | false, |
| 696 | trim_line_required, |
| 697 | ), |
| 698 | line_no, |
| 699 | col_no, |
| 700 | ); |
| 701 | } |
| 702 | |
| 703 | // reset standalone statement marker |
| 704 | trim_line_required = false; |
| 705 | } |
| 706 | |
| 707 | let (line_no, col_no) = span.start_posrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]start_pos().().line_colrust-analyzer cargo pest 2.7.8 position/impl#[`Position<'i>`]line_col().(); |
| 708 | match rule { |
| 709 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::templaterust-analyzer cargo handlebars 5.1.2 grammar/Rule#template# => { |
| 710 | template_stack.push_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_front().(Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::newrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]new().()); |
| 711 | } |
| 712 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::raw_textrust-analyzer cargo handlebars 5.1.2 grammar/Rule#raw_text# => { |
| 713 | // leading space fix |
| 714 | let start = if span.startrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]start().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().prev_end { |
| 715 | prev_end |
| 716 | } else { |
| 717 | span.startrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]start().() |
| 718 | }; |
| 719 | |
| 720 | let t = template_stack.front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 721 | t.push_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]push_element().( |
| 722 | Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::raw_stringrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]raw_string().( |
| 723 | &source[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., |
| 724 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pair.clonerust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`][Clone]clone().()), |
| 725 | omit_pro_ws, |
| 726 | trim_line_required, |
| 727 | ), |
| 728 | line_no, |
| 729 | col_no, |
| 730 | ); |
| 731 | |
| 732 | // reset standalone statement marker |
| 733 | trim_line_required = false; |
| 734 | } |
| 735 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::helper_block_startrust-analyzer cargo handlebars 5.1.2 grammar/Rule#helper_block_start# |
| 736 | | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::raw_block_startrust-analyzer cargo handlebars 5.1.2 grammar/Rule#raw_block_start# |
| 737 | | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::decorator_block_startrust-analyzer cargo handlebars 5.1.2 grammar/Rule#decorator_block_start# |
| 738 | | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::partial_block_startrust-analyzer cargo handlebars 5.1.2 grammar/Rule#partial_block_start# => { |
| 739 | let exp = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::parse_expressionrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_expression().(source, it.by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().(), span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 740 | |
| 741 | match rule { |
| 742 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::helper_block_startrust-analyzer cargo handlebars 5.1.2 grammar/Rule#helper_block_start# | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::raw_block_startrust-analyzer cargo handlebars 5.1.2 grammar/Rule#raw_block_start# => { |
| 743 | let helper_template = HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#::newrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]new().(exp.clonerust-analyzer cargo handlebars 5.1.2 template/impl#[ExpressionSpec][Clone]clone().(), true); |
| 744 | helper_stack.push_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_front().(helper_template); |
| 745 | } |
| 746 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::decorator_block_startrust-analyzer cargo handlebars 5.1.2 grammar/Rule#decorator_block_start# | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::partial_block_startrust-analyzer cargo handlebars 5.1.2 grammar/Rule#partial_block_start# => { |
| 747 | let decorator = DecoratorTemplaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#::newrust-analyzer cargo handlebars 5.1.2 template/impl#[DecoratorTemplate]new().(exp.clonerust-analyzer cargo handlebars 5.1.2 template/impl#[ExpressionSpec][Clone]clone().()); |
| 748 | decorator_stack.push_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_front().(decorator); |
| 749 | } |
| 750 | _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 751 | } |
| 752 | |
| 753 | if exp.omit_pre_wsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#omit_pre_ws. { |
| 754 | Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::remove_previous_whitespacerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]remove_previous_whitespace().(&mut template_stack); |
| 755 | } |
| 756 | omit_pro_ws = exp.omit_pro_wsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#omit_pro_ws.; |
| 757 | |
| 758 | // standalone statement check, it also removes leading whitespaces of |
| 759 | // previous rawstring when standalone statement detected |
| 760 | trim_line_required = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::process_standalone_statementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]process_standalone_statement().( |
| 761 | &mut template_stack, |
| 762 | source, |
| 763 | &span, |
| 764 | true, |
| 765 | ); |
| 766 | |
| 767 | let t = template_stack.front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 768 | t.mappingrust-analyzer cargo handlebars 5.1.2 template/Template#mapping..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(TemplateMappingrust-analyzer cargo handlebars 5.1.2 template/TemplateMapping#(line_no, col_no)); |
| 769 | } |
| 770 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::invert_tagrust-analyzer cargo handlebars 5.1.2 grammar/Rule#invert_tag# | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::invert_chain_tagrust-analyzer cargo handlebars 5.1.2 grammar/Rule#invert_chain_tag# => { |
| 771 | // hack: invert_tag structure is similar to ExpressionSpec, so I |
| 772 | // use it here to represent the data |
| 773 | |
| 774 | if rule rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().==rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq(). rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::invert_chain_tagrust-analyzer cargo handlebars 5.1.2 grammar/Rule#invert_chain_tag# { |
| 775 | let _ = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::parse_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_name().(source, &mut it, span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 776 | } |
| 777 | let exp = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::parse_expressionrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_expression().(source, it.by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().(), span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 778 | |
| 779 | if exp.omit_pre_wsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#omit_pre_ws. { |
| 780 | Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::remove_previous_whitespacerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]remove_previous_whitespace().(&mut template_stack); |
| 781 | } |
| 782 | omit_pro_ws = exp.omit_pro_wsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#omit_pro_ws.; |
| 783 | |
| 784 | // standalone statement check, it also removes leading whitespaces of |
| 785 | // previous rawstring when standalone statement detected |
| 786 | trim_line_required = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::process_standalone_statementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]process_standalone_statement().( |
| 787 | &mut template_stack, |
| 788 | source, |
| 789 | &span, |
| 790 | true, |
| 791 | ); |
| 792 | |
| 793 | let t = template_stack.pop_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]pop_front().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 794 | let h = helper_stack.front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 795 | |
| 796 | if rule rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().==rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq(). rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::invert_chain_tagrust-analyzer cargo handlebars 5.1.2 grammar/Rule#invert_chain_tag# { |
| 797 | h.set_chainedrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]set_chained().(); |
| 798 | } |
| 799 | |
| 800 | h.set_chain_templaterust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]set_chain_template().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(t)); |
| 801 | if rule rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().==rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq(). rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::invert_chain_tagrust-analyzer cargo handlebars 5.1.2 grammar/Rule#invert_chain_tag# { |
| 802 | h.insert_inverse_noderust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]insert_inverse_node().(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().(HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#::new_chainrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]new_chain().(exp, true))); |
| 803 | } |
| 804 | } |
| 805 | |
| 806 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::raw_block_textrust-analyzer cargo handlebars 5.1.2 grammar/Rule#raw_block_text# => { |
| 807 | let mut t = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::newrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]new().(); |
| 808 | t.push_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]push_element().( |
| 809 | Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::raw_stringrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]raw_string().( |
| 810 | span.as_strrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]as_str().(), |
| 811 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pair.clonerust-analyzer cargo pest 2.7.8 iterators/pair/impl#[`Pair<'i, R>`][Clone]clone().()), |
| 812 | omit_pro_ws, |
| 813 | trim_line_required, |
| 814 | ), |
| 815 | line_no, |
| 816 | col_no, |
| 817 | ); |
| 818 | template_stack.push_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_front().(t); |
| 819 | } |
| 820 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::expressionrust-analyzer cargo handlebars 5.1.2 grammar/Rule#expression# |
| 821 | | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::html_expressionrust-analyzer cargo handlebars 5.1.2 grammar/Rule#html_expression# |
| 822 | | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::decorator_expressionrust-analyzer cargo handlebars 5.1.2 grammar/Rule#decorator_expression# |
| 823 | | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::partial_expressionrust-analyzer cargo handlebars 5.1.2 grammar/Rule#partial_expression# |
| 824 | | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::helper_block_endrust-analyzer cargo handlebars 5.1.2 grammar/Rule#helper_block_end# |
| 825 | | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::raw_block_endrust-analyzer cargo handlebars 5.1.2 grammar/Rule#raw_block_end# |
| 826 | | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::decorator_block_endrust-analyzer cargo handlebars 5.1.2 grammar/Rule#decorator_block_end# |
| 827 | | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::partial_block_endrust-analyzer cargo handlebars 5.1.2 grammar/Rule#partial_block_end# => { |
| 828 | let exp = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::parse_expressionrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]parse_expression().(source, it.by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().(), span.endrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 829 | |
| 830 | if exp.omit_pre_wsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#omit_pre_ws. { |
| 831 | Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::remove_previous_whitespacerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]remove_previous_whitespace().(&mut template_stack); |
| 832 | } |
| 833 | omit_pro_ws = exp.omit_pro_wsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#omit_pro_ws.; |
| 834 | |
| 835 | match rule { |
| 836 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::expressionrust-analyzer cargo handlebars 5.1.2 grammar/Rule#expression# | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::html_expressionrust-analyzer cargo handlebars 5.1.2 grammar/Rule#html_expression# => { |
| 837 | let helper_template = HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#::newrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]new().(exp.clonerust-analyzer cargo handlebars 5.1.2 template/impl#[ExpressionSpec][Clone]clone().(), false); |
| 838 | let el = if rule rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().==rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq(). rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::expressionrust-analyzer cargo handlebars 5.1.2 grammar/Rule#expression# { |
| 839 | Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(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().(helper_template)) |
| 840 | } else { |
| 841 | HtmlExpressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HtmlExpression#(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().(helper_template)) |
| 842 | }; |
| 843 | let t = template_stack.front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 844 | t.push_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]push_element().(el, line_no, col_no); |
| 845 | } |
| 846 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::decorator_expressionrust-analyzer cargo handlebars 5.1.2 grammar/Rule#decorator_expression# | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::partial_expressionrust-analyzer cargo handlebars 5.1.2 grammar/Rule#partial_expression# => { |
| 847 | // do not auto trim ident spaces for |
| 848 | // partial_expression(>) |
| 849 | let prevent_indent = rule rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::partial_expressionrust-analyzer cargo handlebars 5.1.2 grammar/Rule#partial_expression#; |
| 850 | trim_line_required = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::process_standalone_statementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]process_standalone_statement().( |
| 851 | &mut template_stack, |
| 852 | source, |
| 853 | &span, |
| 854 | prevent_indent, |
| 855 | ); |
| 856 | |
| 857 | // indent for partial expression > |
| 858 | let mut indent = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 859 | if rule rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().==rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq(). rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::partial_expressionrust-analyzer cargo handlebars 5.1.2 grammar/Rule#partial_expression# |
| 860 | && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().options.prevent_indentrust-analyzer cargo handlebars 5.1.2 template/TemplateOptions#prevent_indent. |
| 861 | && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().exp.omit_pre_wsrust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#omit_pre_ws. |
| 862 | { |
| 863 | indent = supportrust-analyzer cargo handlebars 5.1.2 support/::strrust-analyzer cargo handlebars 5.1.2 support/str/::find_trailing_whitespace_charsrust-analyzer cargo handlebars 5.1.2 support/str/find_trailing_whitespace_chars().( |
| 864 | &source[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#span.startrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]start().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., |
| 865 | ); |
| 866 | } |
| 867 | |
| 868 | let mut decorator = DecoratorTemplaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#::newrust-analyzer cargo handlebars 5.1.2 template/impl#[DecoratorTemplate]new().(exp.clonerust-analyzer cargo handlebars 5.1.2 template/impl#[ExpressionSpec][Clone]clone().()); |
| 869 | decorator.indentrust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#indent. = indent.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 870 | |
| 871 | let el = if rule rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().==rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq(). rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::decorator_expressionrust-analyzer cargo handlebars 5.1.2 grammar/Rule#decorator_expression# { |
| 872 | DecoratorExpressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#DecoratorExpression#(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().(decorator)) |
| 873 | } else { |
| 874 | PartialExpressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#PartialExpression#(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().(decorator)) |
| 875 | }; |
| 876 | let t = template_stack.front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 877 | t.push_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]push_element().(el, line_no, col_no); |
| 878 | } |
| 879 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::helper_block_endrust-analyzer cargo handlebars 5.1.2 grammar/Rule#helper_block_end# | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::raw_block_endrust-analyzer cargo handlebars 5.1.2 grammar/Rule#raw_block_end# => { |
| 880 | // standalone statement check, it also removes leading whitespaces of |
| 881 | // previous rawstring when standalone statement detected |
| 882 | trim_line_required = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::process_standalone_statementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]process_standalone_statement().( |
| 883 | &mut template_stack, |
| 884 | source, |
| 885 | &span, |
| 886 | true, |
| 887 | ); |
| 888 | |
| 889 | let mut h = helper_stack.pop_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]pop_front().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 890 | let close_tag_name = exp.namerust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#name..as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().(); |
| 891 | if h.namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name..as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().close_tag_name { |
| 892 | let prev_t = template_stack.pop_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]pop_front().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 893 | h.revert_chain_and_setrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]revert_chain_and_set().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(prev_t)); |
| 894 | |
| 895 | let t = template_stack.front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 896 | t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(HelperBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HelperBlock#(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().(h))); |
| 897 | } else { |
| 898 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#::ofrust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]of().( |
| 899 | TemplateErrorReasonrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#::MismatchingClosedHelperrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#MismatchingClosedHelper#( |
| 900 | h.namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name..debug_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]debug_name().(), |
| 901 | exp.namerust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#name..debug_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]debug_name().(), |
| 902 | ), |
| 903 | ) |
| 904 | .atrust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]at().(source, line_no, col_no) |
| 905 | .in_templaterust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]in_template().(options.namerust-analyzer cargo handlebars 5.1.2 template/impl#[TemplateOptions]name().())); |
| 906 | } |
| 907 | } |
| 908 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::decorator_block_endrust-analyzer cargo handlebars 5.1.2 grammar/Rule#decorator_block_end# | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::partial_block_endrust-analyzer cargo handlebars 5.1.2 grammar/Rule#partial_block_end# => { |
| 909 | // standalone statement check, it also removes leading whitespaces of |
| 910 | // previous rawstring when standalone statement detected |
| 911 | trim_line_required = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::process_standalone_statementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]process_standalone_statement().( |
| 912 | &mut template_stack, |
| 913 | source, |
| 914 | &span, |
| 915 | true, |
| 916 | ); |
| 917 | |
| 918 | let mut d = decorator_stack.pop_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]pop_front().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 919 | let close_tag_name = exp.namerust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#name..as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().(); |
| 920 | if d.namerust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#name..as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().close_tag_name { |
| 921 | let prev_t = template_stack.pop_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]pop_front().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 922 | d.templaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#template. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(prev_t); |
| 923 | let t = template_stack.front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 924 | if rule rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().==rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq(). rust-analyzer cargo handlebars 5.1.2 grammar/impl#[Rule][`PartialEq<Self>`]eq().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::decorator_block_endrust-analyzer cargo handlebars 5.1.2 grammar/Rule#decorator_block_end# { |
| 925 | t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(DecoratorBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#DecoratorBlock#(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().(d))); |
| 926 | } else { |
| 927 | t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(PartialBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#PartialBlock#(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().(d))); |
| 928 | } |
| 929 | } else { |
| 930 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#::ofrust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]of().( |
| 931 | TemplateErrorReasonrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#::MismatchingClosedDecoratorrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#MismatchingClosedDecorator#( |
| 932 | d.namerust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#name..debug_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]debug_name().(), |
| 933 | exp.namerust-analyzer cargo handlebars 5.1.2 template/ExpressionSpec#name..debug_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]debug_name().(), |
| 934 | ), |
| 935 | ) |
| 936 | .atrust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]at().(source, line_no, col_no) |
| 937 | .in_templaterust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]in_template().(options.namerust-analyzer cargo handlebars 5.1.2 template/impl#[TemplateOptions]name().())); |
| 938 | } |
| 939 | } |
| 940 | _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 941 | } |
| 942 | } |
| 943 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::hbs_comment_compactrust-analyzer cargo handlebars 5.1.2 grammar/Rule#hbs_comment_compact# => { |
| 944 | trim_line_required = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::process_standalone_statementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]process_standalone_statement().( |
| 945 | &mut template_stack, |
| 946 | source, |
| 947 | &span, |
| 948 | true, |
| 949 | ); |
| 950 | |
| 951 | let text = span |
| 952 | .as_strrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]as_str().() |
| 953 | .trim_start_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start_matches().("{{!") |
| 954 | .trim_end_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_end_matches().("}}"); |
| 955 | let t = template_stack.front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 956 | t.push_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]push_element().(Commentrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Comment#(text.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), line_no, col_no); |
| 957 | } |
| 958 | Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::hbs_commentrust-analyzer cargo handlebars 5.1.2 grammar/Rule#hbs_comment# => { |
| 959 | trim_line_required = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::process_standalone_statementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]process_standalone_statement().( |
| 960 | &mut template_stack, |
| 961 | source, |
| 962 | &span, |
| 963 | true, |
| 964 | ); |
| 965 | |
| 966 | let text = span |
| 967 | .as_strrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]as_str().() |
| 968 | .trim_start_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start_matches().("{{!--") |
| 969 | .trim_end_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_end_matches().("--}}"); |
| 970 | let t = template_stack.front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 971 | t.push_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]push_element().(Commentrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Comment#(text.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), line_no, col_no); |
| 972 | } |
| 973 | _ => {} |
| 974 | } |
| 975 | |
| 976 | if rule rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Rulerust-analyzer cargo handlebars 5.1.2 grammar/Rule#::templaterust-analyzer cargo handlebars 5.1.2 grammar/Rule#template# { |
| 977 | end_pos = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(span.end_posrust-analyzer cargo pest 2.7.8 span/impl#[`Span<'i>`]end_pos().()); |
| 978 | } |
| 979 | } else { |
| 980 | let prev_end = end_pos.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|e| e.posrust-analyzer cargo pest 2.7.8 position/impl#[`Position<'i>`]pos().()).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0); |
| 981 | if prev_end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().source.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() { |
| 982 | let text = &source[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().prev_end..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#source.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 983 | // is some called in if check |
| 984 | let (line_no, col_no) = end_pos.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().line_colrust-analyzer cargo pest 2.7.8 position/impl#[`Position<'i>`]line_col().(); |
| 985 | let t = template_stack.front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 986 | t.push_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]push_element().(RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#(text.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), line_no, col_no); |
| 987 | } |
| 988 | let mut root_template = template_stack.pop_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]pop_front().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 989 | root_template.namerust-analyzer cargo handlebars 5.1.2 template/Template#name. = options.namerust-analyzer cargo handlebars 5.1.2 template/TemplateOptions#name.; |
| 990 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(root_template); |
| 991 | } |
| 992 | } |
| 993 | } |
| 994 | |
| 995 | // These two compile functions are kept for compatibility with 4.x |
| 996 | // Template APIs in case that some developers are using them |
| 997 | // without registry. |
| 998 | |
| 999 | pub fn compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().(source: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Templaterust-analyzer cargo handlebars 5.1.2 template/Template#, TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#> { |
| 1000 | Selfrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]::compile2rust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile2().(source, TemplateOptionsrust-analyzer cargo handlebars 5.1.2 template/TemplateOptions#::defaultrust-analyzer cargo handlebars 5.1.2 template/impl#[TemplateOptions][Default]default().()) |
| 1001 | } |
| 1002 | |
| 1003 | pub fn compile_with_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile_with_name().<S: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>>( |
| 1004 | source: S, |
| 1005 | name: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 1006 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Templaterust-analyzer cargo handlebars 5.1.2 template/Template#, TemplateErrorrust-analyzer cargo handlebars 5.1.2 error/TemplateError#> { |
| 1007 | Selfrust-analyzer cargo handlebars 5.1.2 template/impl#[Template]::compile2rust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile2().( |
| 1008 | source.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().(), |
| 1009 | TemplateOptionsrust-analyzer cargo handlebars 5.1.2 template/TemplateOptions# { |
| 1010 | namerust-analyzer cargo handlebars 5.1.2 template/TemplateOptions#name.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(name), |
| 1011 | ..Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo handlebars 5.1.2 template/impl#[TemplateOptions][Default]default().() |
| 1012 | }, |
| 1013 | ) |
| 1014 | } |
| 1015 | } |
| 1016 | |
| 1017 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 1018 | pub enum TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement# { |
| 1019 | RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#), |
| 1020 | HtmlExpressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HtmlExpression#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#>), |
| 1021 | Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#>), |
| 1022 | HelperBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HelperBlock#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#>), |
| 1023 | DecoratorExpressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#DecoratorExpression#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<DecoratorTemplaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#>), |
| 1024 | DecoratorBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#DecoratorBlock#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<DecoratorTemplaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#>), |
| 1025 | PartialExpressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#PartialExpression#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<DecoratorTemplaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#>), |
| 1026 | PartialBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#PartialBlock#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<DecoratorTemplaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#>), |
| 1027 | Commentrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Comment#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#), |
| 1028 | } |
| 1029 | |
| 1030 | #[cfg(test)] |
| 1031 | mod testrust-analyzer cargo handlebars 5.1.2 template/test/ { |
| 1032 | use superrust-analyzer cargo handlebars 5.1.2 template/::*; |
| 1033 | use craterust-analyzer cargo handlebars 5.1.2 crate/::errorrust-analyzer cargo handlebars 5.1.2 error/::TemplateErrorReasonrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#; |
| 1034 | |
| 1035 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1036 | fn test_parse_escaped_tag_raw_stringrust-analyzer cargo handlebars 5.1.2 template/test/test_parse_escaped_tag_raw_string().() { |
| 1037 | let source = r"foo \{{bar}}"; |
| 1038 | let t = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().(source).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().(); |
| 1039 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1040 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1041 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 1042 | RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#("foo {{bar}}".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 1043 | ); |
| 1044 | } |
| 1045 | |
| 1046 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1047 | fn test_pure_backslash_raw_stringrust-analyzer cargo handlebars 5.1.2 template/test/test_pure_backslash_raw_string().() { |
| 1048 | let source = r"\\\\"; |
| 1049 | let t = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().(source).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().(); |
| 1050 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1051 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#(source.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 1052 | } |
| 1053 | |
| 1054 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1055 | fn test_parse_escaped_block_raw_stringrust-analyzer cargo handlebars 5.1.2 template/test/test_parse_escaped_block_raw_string().() { |
| 1056 | let source = r"\{{{{foo}}}} bar"; |
| 1057 | let t = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().(source).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().(); |
| 1058 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1059 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1060 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 1061 | RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#("{{{{foo}}}} bar".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 1062 | ); |
| 1063 | } |
| 1064 | |
| 1065 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1066 | fn test_parse_templaterust-analyzer cargo handlebars 5.1.2 template/test/test_parse_template().() { |
| 1067 | let source = "<h1>{{title}} 你好</h1> {{{content}}} |
| 1068 | {{#if date}}<p>good</p>{{else}}<p>bad</p>{{/if}}<img>{{foo bar}}中文你好 |
| 1069 | {{#unless true}}kitkat{{^}}lollipop{{/unless}}"; |
| 1070 | let t = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().(source).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().(); |
| 1071 | |
| 1072 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 10); |
| 1073 | |
| 1074 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#("<h1>".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 1075 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1076 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 1077 | Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(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().(HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#::with_pathrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]with_path().(Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#::with_named_pathsrust-analyzer cargo handlebars 5.1.2 json/path/impl#[Path]with_named_paths().( |
| 1078 | &["title"] |
| 1079 | )))) |
| 1080 | ); |
| 1081 | |
| 1082 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1083 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(3).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 1084 | HtmlExpressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HtmlExpression#(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().(HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#::with_pathrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]with_path().(Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#::with_named_pathsrust-analyzer cargo handlebars 5.1.2 json/path/impl#[Path]with_named_paths().( |
| 1085 | &["content"], |
| 1086 | )))) |
| 1087 | ); |
| 1088 | |
| 1089 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(5).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() { |
| 1090 | HelperBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HelperBlock#(ref h) => { |
| 1091 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name..as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "if".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 1092 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1093 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.templaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#template..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1094 | } |
| 1095 | _ => { |
| 1096 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Helper expected here."); |
| 1097 | } |
| 1098 | }; |
| 1099 | |
| 1100 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(7).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() { |
| 1101 | Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(ref h) => { |
| 1102 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name..as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "foo".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 1103 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1104 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1105 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().(h.paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()), |
| 1106 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Pathrust-analyzer cargo handlebars 5.1.2 template/Parameter#Path#(Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#::with_named_pathsrust-analyzer cargo handlebars 5.1.2 json/path/impl#[Path]with_named_paths().(&["bar"])) |
| 1107 | ) |
| 1108 | } |
| 1109 | _ => { |
| 1110 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Helper expression here"); |
| 1111 | } |
| 1112 | }; |
| 1113 | |
| 1114 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(9).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() { |
| 1115 | HelperBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HelperBlock#(ref h) => { |
| 1116 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name..as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "unless".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 1117 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1118 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1119 | } |
| 1120 | _ => { |
| 1121 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Helper expression here"); |
| 1122 | } |
| 1123 | }; |
| 1124 | } |
| 1125 | |
| 1126 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1127 | fn test_parse_block_partial_path_identifierrust-analyzer cargo handlebars 5.1.2 template/test/test_parse_block_partial_path_identifier().() { |
| 1128 | let source = "{{#> foo/bar}}{{/foo/bar}}"; |
| 1129 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().(source).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1130 | } |
| 1131 | |
| 1132 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1133 | fn test_parse_errorrust-analyzer cargo handlebars 5.1.2 template/test/test_parse_error().() { |
| 1134 | let source = "{{#ifequals name compare=\"hello\"}}\nhello\n\t{{else}}\ngood"; |
| 1135 | |
| 1136 | let terr = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().(source).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 1137 | |
| 1138 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!( |
| 1139 | terr.reasonrust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]reason().(), |
| 1140 | TemplateErrorReasonrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#::InvalidSyntaxrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#InvalidSyntax#(_) |
| 1141 | )); |
| 1142 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(terr.posrust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]pos().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((4, 5))); |
| 1143 | } |
| 1144 | |
| 1145 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1146 | fn test_subexpressionrust-analyzer cargo handlebars 5.1.2 template/test/test_subexpression().() { |
| 1147 | let source = |
| 1148 | "{{foo (bar)}}{{foo (bar baz)}} hello {{#if (baz bar) then=(bar)}}world{{/if}}"; |
| 1149 | let t = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().(source).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().(); |
| 1150 | |
| 1151 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 4); |
| 1152 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() { |
| 1153 | Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(ref h) => { |
| 1154 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name..as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "foo".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 1155 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1156 | if let &Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Subexpressionrust-analyzer cargo handlebars 5.1.2 template/Parameter#Subexpression#(ref t) = h.paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() { |
| 1157 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.namerust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]name().(), "bar".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 1158 | } else { |
| 1159 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Subexpression expected"); |
| 1160 | } |
| 1161 | } |
| 1162 | _ => { |
| 1163 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Helper expression expected"); |
| 1164 | } |
| 1165 | }; |
| 1166 | |
| 1167 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() { |
| 1168 | Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(ref h) => { |
| 1169 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name..as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "foo".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 1170 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1171 | if let &Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Subexpressionrust-analyzer cargo handlebars 5.1.2 template/Parameter#Subexpression#(ref t) = h.paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() { |
| 1172 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.namerust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]name().(), "bar".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 1173 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Pathrust-analyzer cargo handlebars 5.1.2 template/Parameter#Path#(p)) = t.paramsrust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]params().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(0) { |
| 1174 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p, &Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#::with_named_pathsrust-analyzer cargo handlebars 5.1.2 json/path/impl#[Path]with_named_paths().(&["baz"])); |
| 1175 | } else { |
| 1176 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("non-empty param expected "); |
| 1177 | } |
| 1178 | } else { |
| 1179 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Subexpression expected"); |
| 1180 | } |
| 1181 | } |
| 1182 | _ => { |
| 1183 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Helper expression expected"); |
| 1184 | } |
| 1185 | }; |
| 1186 | |
| 1187 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(3).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() { |
| 1188 | HelperBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HelperBlock#(ref h) => { |
| 1189 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name..as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "if".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 1190 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1191 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.hashrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#hash..lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]len().(), 1); |
| 1192 | |
| 1193 | if let &Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Subexpressionrust-analyzer cargo handlebars 5.1.2 template/Parameter#Subexpression#(ref t) = h.paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() { |
| 1194 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.namerust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]name().(), "baz".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 1195 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Pathrust-analyzer cargo handlebars 5.1.2 template/Parameter#Path#(p)) = t.paramsrust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]params().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(0) { |
| 1196 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(p, &Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#::with_named_pathsrust-analyzer cargo handlebars 5.1.2 json/path/impl#[Path]with_named_paths().(&["bar"])); |
| 1197 | } else { |
| 1198 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("non-empty param expected "); |
| 1199 | } |
| 1200 | } else { |
| 1201 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Subexpression expected (baz bar)"); |
| 1202 | } |
| 1203 | |
| 1204 | if let &Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Subexpressionrust-analyzer cargo handlebars 5.1.2 template/Parameter#Subexpression#(ref t) = h.hashrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#hash..getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().("then").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() { |
| 1205 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.namerust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]name().(), "bar".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 1206 | } else { |
| 1207 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Subexpression expected (bar)"); |
| 1208 | } |
| 1209 | } |
| 1210 | _ => { |
| 1211 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("HelperBlock expected"); |
| 1212 | } |
| 1213 | } |
| 1214 | } |
| 1215 | |
| 1216 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1217 | fn test_white_space_omitterrust-analyzer cargo handlebars 5.1.2 template/test/test_white_space_omitter().() { |
| 1218 | let source = "hello~ {{~world~}} \n !{{~#if true}}else{{/if~}}"; |
| 1219 | let t = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().(source).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().(); |
| 1220 | |
| 1221 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 4); |
| 1222 | |
| 1223 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#("hello~".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 1224 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1225 | t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., |
| 1226 | Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(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().(HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#::with_pathrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]with_path().(Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#::with_named_pathsrust-analyzer cargo handlebars 5.1.2 json/path/impl#[Path]with_named_paths().( |
| 1227 | &["world"] |
| 1228 | )))) |
| 1229 | ); |
| 1230 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#("!".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())); |
| 1231 | |
| 1232 | let t2 = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().("{{#if true}}1 {{~ else ~}} 2 {{~/if}}") |
| 1233 | .okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().() |
| 1234 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 1235 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t2.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1236 | match t2.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). { |
| 1237 | HelperBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HelperBlock#(ref h) => { |
| 1238 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1239 | h.templaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#template..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., |
| 1240 | RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#("1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 1241 | ); |
| 1242 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1243 | h.inverserust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#inverse..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., |
| 1244 | RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#("2".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 1245 | ); |
| 1246 | } |
| 1247 | _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 1248 | } |
| 1249 | } |
| 1250 | |
| 1251 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1252 | fn test_unclosed_expressionrust-analyzer cargo handlebars 5.1.2 template/test/test_unclosed_expression().() { |
| 1253 | let sources = ["{{invalid", "{{{invalid", "{{invalid}", "{{!hello"]; |
| 1254 | for s in sources.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() { |
| 1255 | let result = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().(s.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[T][ToOwned]to_owned().()); |
| 1256 | let err = result.expect_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect_err().("expected a syntax error"); |
| 1257 | let syntax_error_msg = match err.reasonrust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]reason().() { |
| 1258 | TemplateErrorReasonrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#::InvalidSyntaxrust-analyzer cargo handlebars 5.1.2 error/TemplateErrorReason#InvalidSyntax#(s) => s, |
| 1259 | _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("InvalidSyntax expected"), |
| 1260 | }; |
| 1261 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 1262 | syntax_error_msg.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("expected identifier"), |
| 1263 | "{}", |
| 1264 | syntax_error_msg |
| 1265 | ); |
| 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1270 | fn test_raw_helperrust-analyzer cargo handlebars 5.1.2 template/test/test_raw_helper().() { |
| 1271 | let source = "hello{{{{raw}}}}good{{night}}{{{{/raw}}}}world"; |
| 1272 | match Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().(source) { |
| 1273 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(t) => { |
| 1274 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 3); |
| 1275 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#("hello".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())); |
| 1276 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#("world".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())); |
| 1277 | match t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). { |
| 1278 | HelperBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HelperBlock#(ref h) => { |
| 1279 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(h.namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name..as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "raw".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()); |
| 1280 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref ht) = h.templaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#template. { |
| 1281 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ht.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1282 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1283 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().ht.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 1284 | RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#("good{{night}}".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()) |
| 1285 | ); |
| 1286 | } else { |
| 1287 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("helper template not found"); |
| 1288 | } |
| 1289 | } |
| 1290 | _ => { |
| 1291 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Unexpected element type"); |
| 1292 | } |
| 1293 | } |
| 1294 | } |
| 1295 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => { |
| 1296 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("{}", e); |
| 1297 | } |
| 1298 | } |
| 1299 | } |
| 1300 | |
| 1301 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1302 | fn test_literal_parameter_parserrust-analyzer cargo handlebars 5.1.2 template/test/test_literal_parameter_parser().() { |
| 1303 | match Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().("{{hello 1 name=\"value\" valid=false ref=someref}}") { |
| 1304 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(t) => { |
| 1305 | if let Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(ref ht) = t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). { |
| 1306 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ht.paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Literalrust-analyzer cargo handlebars 5.1.2 template/Parameter#Literal#(jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!(1))); |
| 1307 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1308 | ht.hashrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#hash.[rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Index<&Q>`]index()."name"]rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Index<&Q>`]index()., |
| 1309 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Literalrust-analyzer cargo handlebars 5.1.2 template/Parameter#Literal#(Jsonrust-analyzer cargo serde_json 1.0.114 value/Value#::Stringrust-analyzer cargo serde_json 1.0.114 value/Value#String#("value".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())) |
| 1310 | ); |
| 1311 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ht.hashrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#hash.[rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Index<&Q>`]index()."valid"]rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Index<&Q>`]index()., Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Literalrust-analyzer cargo handlebars 5.1.2 template/Parameter#Literal#(Jsonrust-analyzer cargo serde_json 1.0.114 value/Value#::Boolrust-analyzer cargo serde_json 1.0.114 value/Value#Bool#(false))); |
| 1312 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1313 | ht.hashrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#hash.[rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Index<&Q>`]index()."ref"]rust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][`Index<&Q>`]index()., |
| 1314 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Pathrust-analyzer cargo handlebars 5.1.2 template/Parameter#Path#(Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#::with_named_pathsrust-analyzer cargo handlebars 5.1.2 json/path/impl#[Path]with_named_paths().(&["someref"])) |
| 1315 | ); |
| 1316 | } |
| 1317 | } |
| 1318 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("{}", e), |
| 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1323 | fn test_template_mappingrust-analyzer cargo handlebars 5.1.2 template/test/test_template_mapping().() { |
| 1324 | match Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().("hello\n {{~world}}\n{{#if nice}}\n\thello\n{{/if}}") { |
| 1325 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(t) => { |
| 1326 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.mappingrust-analyzer cargo handlebars 5.1.2 template/Template#mapping..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()); |
| 1327 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.mappingrust-analyzer cargo handlebars 5.1.2 template/Template#mapping.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., TemplateMappingrust-analyzer cargo handlebars 5.1.2 template/TemplateMapping#(1, 1)); |
| 1328 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.mappingrust-analyzer cargo handlebars 5.1.2 template/Template#mapping.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., TemplateMappingrust-analyzer cargo handlebars 5.1.2 template/TemplateMapping#(2, 3)); |
| 1329 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.mappingrust-analyzer cargo handlebars 5.1.2 template/Template#mapping.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().3]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., TemplateMappingrust-analyzer cargo handlebars 5.1.2 template/TemplateMapping#(3, 1)); |
| 1330 | } |
| 1331 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("{}", e), |
| 1332 | } |
| 1333 | } |
| 1334 | |
| 1335 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1336 | fn test_whitespace_elementsrust-analyzer cargo handlebars 5.1.2 template/test/test_whitespace_elements().() { |
| 1337 | let c = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().( |
| 1338 | " {{elem}}\n\t{{#if true}} \ |
| 1339 | {{/if}}\n{{{{raw}}}} {{{{/raw}}}}\n{{{{raw}}}}{{{{/raw}}}}\n", |
| 1340 | ); |
| 1341 | let r = c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1342 | // the \n after last raw block is dropped by pest |
| 1343 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 9); |
| 1344 | } |
| 1345 | |
| 1346 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1347 | fn test_block_paramrust-analyzer cargo handlebars 5.1.2 template/test/test_block_param().() { |
| 1348 | match Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().("{{#each people as |person|}}{{person}}{{/each}}") { |
| 1349 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(t) => { |
| 1350 | if let HelperBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HelperBlock#(ref ht) = t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). { |
| 1351 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(BlockParamrust-analyzer cargo handlebars 5.1.2 template/BlockParam#::Singlerust-analyzer cargo handlebars 5.1.2 template/BlockParam#Single#(Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#(ref n))) = ht.block_paramrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block_param. { |
| 1352 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(n, "person"); |
| 1353 | } else { |
| 1354 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("block param expected.") |
| 1355 | } |
| 1356 | } else { |
| 1357 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Helper block expected"); |
| 1358 | } |
| 1359 | } |
| 1360 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("{}", e), |
| 1361 | } |
| 1362 | |
| 1363 | match Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().("{{#each people as |val key|}}{{person}}{{/each}}") { |
| 1364 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(t) => { |
| 1365 | if let HelperBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HelperBlock#(ref ht) = t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). { |
| 1366 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(BlockParamrust-analyzer cargo handlebars 5.1.2 template/BlockParam#::Pairrust-analyzer cargo handlebars 5.1.2 template/BlockParam#Pair#(( |
| 1367 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#(ref n1), |
| 1368 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#(ref n2), |
| 1369 | ))) = ht.block_paramrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block_param. |
| 1370 | { |
| 1371 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(n1, "val"); |
| 1372 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(n2, "key"); |
| 1373 | } else { |
| 1374 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("helper block param expected."); |
| 1375 | } |
| 1376 | } else { |
| 1377 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Helper block expected"); |
| 1378 | } |
| 1379 | } |
| 1380 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("{}", e), |
| 1381 | } |
| 1382 | } |
| 1383 | |
| 1384 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1385 | fn test_decoratorrust-analyzer cargo handlebars 5.1.2 template/test/test_decorator().() { |
| 1386 | match Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().("hello {{* ssh}} world") { |
| 1387 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("{}", e), |
| 1388 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(t) => { |
| 1389 | if let DecoratorExpressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#DecoratorExpression#(ref de) = t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). { |
| 1390 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(de.namerust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#name..as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("ssh")); |
| 1391 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(de.templaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#template., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1392 | } |
| 1393 | } |
| 1394 | } |
| 1395 | |
| 1396 | match Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().("hello {{> ssh}} world") { |
| 1397 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("{}", e), |
| 1398 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(t) => { |
| 1399 | if let PartialExpressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#PartialExpression#(ref de) = t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). { |
| 1400 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(de.namerust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#name..as_namerust-analyzer cargo handlebars 5.1.2 template/impl#[Parameter]as_name().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("ssh")); |
| 1401 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(de.templaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#template., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1402 | } |
| 1403 | } |
| 1404 | } |
| 1405 | |
| 1406 | match Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().("{{#*inline \"hello\"}}expand to hello{{/inline}}{{> hello}}") { |
| 1407 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("{}", e), |
| 1408 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(t) => { |
| 1409 | if let DecoratorBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#DecoratorBlock#(ref db) = t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). { |
| 1410 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db.namerust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#name., Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#("inline".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())); |
| 1411 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1412 | db.paramsrust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#params.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., |
| 1413 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Literalrust-analyzer cargo handlebars 5.1.2 template/Parameter#Literal#(Jsonrust-analyzer cargo serde_json 1.0.114 value/Value#::Stringrust-analyzer cargo serde_json 1.0.114 value/Value#String#("hello".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())) |
| 1414 | ); |
| 1415 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1416 | db.templaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#template..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., |
| 1417 | TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#::RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#("expand to hello".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()) |
| 1418 | ); |
| 1419 | } |
| 1420 | } |
| 1421 | } |
| 1422 | |
| 1423 | match Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().("{{#> layout \"hello\"}}expand to hello{{/layout}}{{> hello}}") { |
| 1424 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("{}", e), |
| 1425 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(t) => { |
| 1426 | if let PartialBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#PartialBlock#(ref db) = t.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). { |
| 1427 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(db.namerust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#name., Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#("layout".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())); |
| 1428 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1429 | db.paramsrust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#params.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., |
| 1430 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Literalrust-analyzer cargo handlebars 5.1.2 template/Parameter#Literal#(Jsonrust-analyzer cargo serde_json 1.0.114 value/Value#::Stringrust-analyzer cargo serde_json 1.0.114 value/Value#String#("hello".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())) |
| 1431 | ); |
| 1432 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1433 | db.templaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#template..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., |
| 1434 | TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#::RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#("expand to hello".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()) |
| 1435 | ); |
| 1436 | } |
| 1437 | } |
| 1438 | } |
| 1439 | } |
| 1440 | |
| 1441 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1442 | fn test_panic_with_tag_namerust-analyzer cargo handlebars 5.1.2 template/test/test_panic_with_tag_name().() { |
| 1443 | let s = "{{#>(X)}}{{/X}}"; |
| 1444 | let result = Templaterust-analyzer cargo handlebars 5.1.2 template/Template#::compilerust-analyzer cargo handlebars 5.1.2 template/impl#[Template]compile().(s); |
| 1445 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(result.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1446 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("decorator \"Subexpression(Subexpression { element: Expression(HelperTemplate { name: Path(Relative(([Named(\\\"X\\\")], \\\"X\\\"))), params: [], hash: {}, block_param: None, template: None, inverse: None, block: false, chain: false }) })\" was opened, but \"X\" is closing", formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", result.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().().reasonrust-analyzer cargo handlebars 5.1.2 error/impl#[TemplateError]reason().())); |
| 1447 | } |
| 1448 | } |