| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::{Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#, Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#}; |
| 2 | 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/::{BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#, VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#}; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/; |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/::Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#; |
| 5 | |
| 6 | 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#; |
| 7 | |
| 8 | use craterust-analyzer cargo handlebars 5.1.2 crate/::blockrust-analyzer cargo handlebars 5.1.2 block/::BlockContextrust-analyzer cargo handlebars 5.1.2 block/BlockContext#; |
| 9 | use craterust-analyzer cargo handlebars 5.1.2 crate/::contextrust-analyzer cargo handlebars 5.1.2 context/::Contextrust-analyzer cargo handlebars 5.1.2 context/Context#; |
| 10 | use craterust-analyzer cargo handlebars 5.1.2 crate/::errorrust-analyzer cargo handlebars 5.1.2 error/::RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#; |
| 11 | use craterust-analyzer cargo handlebars 5.1.2 crate/::helpersrust-analyzer cargo handlebars 5.1.2 helpers/::HelperDefrust-analyzer cargo handlebars 5.1.2 helpers/HelperDef#; |
| 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/::Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#; |
| 13 | use craterust-analyzer cargo handlebars 5.1.2 crate/::jsonrust-analyzer cargo handlebars 5.1.2 json/::valuerust-analyzer cargo handlebars 5.1.2 json/value/::{JsonRenderrust-analyzer cargo handlebars 5.1.2 json/value/JsonRender#, PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#, ScopedJsonrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#}; |
| 14 | use craterust-analyzer cargo handlebars 5.1.2 crate/::outputrust-analyzer cargo handlebars 5.1.2 output/::{Outputrust-analyzer cargo handlebars 5.1.2 output/Output#, StringOutputrust-analyzer cargo handlebars 5.1.2 output/StringOutput#}; |
| 15 | use craterust-analyzer cargo handlebars 5.1.2 crate/::registryrust-analyzer cargo handlebars 5.1.2 registry/::Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#; |
| 16 | use craterust-analyzer cargo handlebars 5.1.2 crate/::supportrust-analyzer cargo handlebars 5.1.2 support/; |
| 17 | use craterust-analyzer cargo handlebars 5.1.2 crate/::templaterust-analyzer cargo handlebars 5.1.2 template/::TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#::*; |
| 18 | use craterust-analyzer cargo handlebars 5.1.2 crate/::templaterust-analyzer cargo handlebars 5.1.2 template/::{ |
| 19 | BlockParamrust-analyzer cargo handlebars 5.1.2 template/BlockParam#, DecoratorTemplaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#, HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#, Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#, Templaterust-analyzer cargo handlebars 5.1.2 template/Template#, TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#, |
| 20 | TemplateMappingrust-analyzer cargo handlebars 5.1.2 template/TemplateMapping#, |
| 21 | }; |
| 22 | use craterust-analyzer cargo handlebars 5.1.2 crate/::{partialrust-analyzer cargo handlebars 5.1.2 partial/, RenderErrorReasonrust-analyzer cargo handlebars 5.1.2 error/RenderErrorReason#}; |
| 23 | |
| 24 | const HELPER_MISSINGrust-analyzer cargo handlebars 5.1.2 render/HELPER_MISSING.: &str = "helperMissing"; |
| 25 | const BLOCK_HELPER_MISSINGrust-analyzer cargo handlebars 5.1.2 render/BLOCK_HELPER_MISSING.: &str = "blockHelperMissing"; |
| 26 | |
| 27 | /// The context of a render call |
| 28 | /// |
| 29 | /// This context stores information of a render and a writer where generated |
| 30 | /// content is written to. |
| 31 | /// |
| 32 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 33 | pub struct RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc> { |
| 34 | innerrust-analyzer cargo handlebars 5.1.2 render/RenderContext#inner.: Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<RenderContextInnerrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#<'reg, 'rc>>, |
| 35 | blocksrust-analyzer cargo handlebars 5.1.2 render/RenderContext#blocks.: VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<BlockContextrust-analyzer cargo handlebars 5.1.2 block/BlockContext#<'rc>>, |
| 36 | // copy-on-write context |
| 37 | modified_contextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#modified_context.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<Contextrust-analyzer cargo handlebars 5.1.2 context/Context#>>, |
| 38 | } |
| 39 | |
| 40 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 41 | pub struct RenderContextInnerrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#<'reg: 'rc, 'rc> { |
| 42 | partialsrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partials.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, &'rc Templaterust-analyzer cargo handlebars 5.1.2 template/Template#>, |
| 43 | partial_block_stackrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partial_block_stack.: VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#<&'reg Templaterust-analyzer cargo handlebars 5.1.2 template/Template#>, |
| 44 | partial_block_depthrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partial_block_depth.: isize, |
| 45 | local_helpersrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#local_helpers.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<dyn HelperDefrust-analyzer cargo handlebars 5.1.2 helpers/HelperDef# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'rc>>, |
| 46 | /// current template name |
| 47 | current_templaterust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#current_template.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'rc Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 48 | /// root template name |
| 49 | root_templaterust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#root_template.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'reg Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 50 | disable_escaperust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#disable_escape.: bool, |
| 51 | indent_stringrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#indent_string.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'reg Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 52 | } |
| 53 | |
| 54 | impl<'reg: 'rc, 'rc> RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc> { |
| 55 | /// Create a render context |
| 56 | pub fn newrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]new().(root_template: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'reg Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) -> RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc> { |
| 57 | let inner = Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T>`]new().(RenderContextInnerrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner# { |
| 58 | partialsrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partials.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(), |
| 59 | partial_block_stackrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partial_block_stack.: 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().(), |
| 60 | partial_block_depthrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partial_block_depth.: 0, |
| 61 | local_helpersrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#local_helpers.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(), |
| 62 | current_templaterust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#current_template.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 63 | root_templaterust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#root_template., |
| 64 | disable_escaperust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#disable_escape.: false, |
| 65 | indent_stringrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#indent_string.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 66 | }); |
| 67 | |
| 68 | let mut blocks = VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T>`]with_capacity().(5); |
| 69 | blocks.push_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_front().(BlockContextrust-analyzer cargo handlebars 5.1.2 block/BlockContext#::newrust-analyzer cargo handlebars 5.1.2 block/impl#[`BlockContext<'rc>`]new().()); |
| 70 | |
| 71 | let modified_context = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 72 | RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext# { |
| 73 | innerrust-analyzer cargo handlebars 5.1.2 render/RenderContext#inner., |
| 74 | blocksrust-analyzer cargo handlebars 5.1.2 render/RenderContext#blocks., |
| 75 | modified_contextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#modified_context., |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) fn new_for_blockrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]new_for_block().(&self) -> RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc> { |
| 80 | let inner = self.innerrust-analyzer cargo handlebars 5.1.2 render/RenderContext#inner..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][Clone]clone().(); |
| 81 | |
| 82 | let mut blocks = VecDequerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/VecDeque#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T>`]with_capacity().(2); |
| 83 | blocks.push_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_front().(BlockContextrust-analyzer cargo handlebars 5.1.2 block/BlockContext#::newrust-analyzer cargo handlebars 5.1.2 block/impl#[`BlockContext<'rc>`]new().()); |
| 84 | |
| 85 | let modified_context = self.modified_contextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#modified_context..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().(); |
| 86 | |
| 87 | RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext# { |
| 88 | innerrust-analyzer cargo handlebars 5.1.2 render/RenderContext#inner., |
| 89 | blocksrust-analyzer cargo handlebars 5.1.2 render/RenderContext#blocks., |
| 90 | modified_contextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#modified_context., |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | /// Push a block context into render context stack. This is typically |
| 95 | /// called when you entering a block scope. |
| 96 | pub fn push_blockrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]push_block().(&mut self, block: BlockContextrust-analyzer cargo handlebars 5.1.2 block/BlockContext#<'rc>) { |
| 97 | self.blocksrust-analyzer cargo handlebars 5.1.2 render/RenderContext#blocks..push_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_front().(block); |
| 98 | } |
| 99 | |
| 100 | /// Pop and drop current block context. |
| 101 | /// This is typically called when leaving a block scope. |
| 102 | pub fn pop_blockrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]pop_block().(&mut self) { |
| 103 | self.blocksrust-analyzer cargo handlebars 5.1.2 render/RenderContext#blocks..pop_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]pop_front().(); |
| 104 | } |
| 105 | |
| 106 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) fn clear_blocksrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]clear_blocks().(&mut self) { |
| 107 | self.blocksrust-analyzer cargo handlebars 5.1.2 render/RenderContext#blocks..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]clear().(); |
| 108 | } |
| 109 | |
| 110 | /// Borrow a reference to current block context |
| 111 | pub fn blockrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]block().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&BlockContextrust-analyzer cargo handlebars 5.1.2 block/BlockContext#<'rc>> { |
| 112 | self.blocksrust-analyzer cargo handlebars 5.1.2 render/RenderContext#blocks..frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front().() |
| 113 | } |
| 114 | |
| 115 | /// Borrow a mutable reference to current block context in order to |
| 116 | /// modify some data. |
| 117 | pub fn block_mutrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]block_mut().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut BlockContextrust-analyzer cargo handlebars 5.1.2 block/BlockContext#<'rc>> { |
| 118 | self.blocksrust-analyzer cargo handlebars 5.1.2 render/RenderContext#blocks..front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]front_mut().() |
| 119 | } |
| 120 | |
| 121 | fn innerrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner().(&self) -> &RenderContextInnerrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#<'reg, 'rc> { |
| 122 | self.innerrust-analyzer cargo handlebars 5.1.2 render/RenderContext#inner..borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][`Borrow<T>`]borrow().() |
| 123 | } |
| 124 | |
| 125 | fn inner_mutrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner_mut().(&mut self) -> &mut RenderContextInnerrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#<'reg, 'rc> { |
| 126 | Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::make_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`]make_mut().(&mut self.innerrust-analyzer cargo handlebars 5.1.2 render/RenderContext#inner.) |
| 127 | } |
| 128 | |
| 129 | /// Get the modified context data if any |
| 130 | pub fn contextrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]context().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<Contextrust-analyzer cargo handlebars 5.1.2 context/Context#>> { |
| 131 | self.modified_contextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#modified_context..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().() |
| 132 | } |
| 133 | |
| 134 | /// Set new context data into the render process. |
| 135 | /// This is typically called in decorators where user can modify |
| 136 | /// the data they were rendering. |
| 137 | pub fn set_contextrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]set_context().(&mut self, ctx: Contextrust-analyzer cargo handlebars 5.1.2 context/Context#) { |
| 138 | self.modified_contextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#modified_context. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T>`]new().(ctx)) |
| 139 | } |
| 140 | |
| 141 | /// Evaluate a Json path in current scope. |
| 142 | /// |
| 143 | /// Typically you don't need to evaluate it by yourself. |
| 144 | /// The Helper and Decorator API will provide your evaluated value of |
| 145 | /// their parameters and hash data. |
| 146 | pub fn evaluaterust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]evaluate().( |
| 147 | &self, |
| 148 | context: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 149 | relative_path: &str, |
| 150 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<ScopedJsonrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#<'rc>, RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 151 | let path = Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#::parserust-analyzer cargo handlebars 5.1.2 json/path/impl#[Path]parse().(relative_path)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 152 | self.evaluate2rust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]evaluate2().(context, &path) |
| 153 | } |
| 154 | |
| 155 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) fn evaluate2rust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]evaluate2().( |
| 156 | &self, |
| 157 | context: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 158 | path: &Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#, |
| 159 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<ScopedJsonrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#<'rc>, RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 160 | match path { |
| 161 | Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#::Localrust-analyzer cargo handlebars 5.1.2 json/path/Path#Local#((level, name, _)) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self |
| 162 | .get_local_varrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]get_local_var().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().level, name) |
| 163 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|v| ScopedJsonrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#::Derivedrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#Derived#(v.clonerust-analyzer cargo serde_json 1.0.114 value/impl#[Value][Clone]clone().())) |
| 164 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| ScopedJsonrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#::Missingrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#Missing#)), |
| 165 | Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#::Relativerust-analyzer cargo handlebars 5.1.2 json/path/Path#Relative#((segs, _)) => context.navigaterust-analyzer cargo handlebars 5.1.2 context/impl#[Context]navigate().(segs, &self.blocksrust-analyzer cargo handlebars 5.1.2 render/RenderContext#blocks.), |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | /// Get registered partial in this render context |
| 170 | pub fn get_partialrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]get_partial().(&self, name: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Templaterust-analyzer cargo handlebars 5.1.2 template/Template#> { |
| 171 | if name rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().partialrust-analyzer cargo handlebars 5.1.2 partial/::PARTIAL_BLOCKrust-analyzer cargo handlebars 5.1.2 partial/PARTIAL_BLOCK. { |
| 172 | return self |
| 173 | .innerrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner().() |
| 174 | .partial_block_stackrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partial_block_stack. |
| 175 | .getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]get().(self.innerrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner().().partial_block_depthrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partial_block_depth. as usize) |
| 176 | .copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]copied().(); |
| 177 | } |
| 178 | self.innerrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner().().partialsrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partials..getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get().(name).copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]copied().() |
| 179 | } |
| 180 | |
| 181 | /// Register a partial for this context |
| 182 | pub fn set_partialrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]set_partial().(&mut self, name: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, partial: &'rc Templaterust-analyzer cargo handlebars 5.1.2 template/Template#) { |
| 183 | self.inner_mutrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner_mut().().partialsrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partials..insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(name, partial); |
| 184 | } |
| 185 | |
| 186 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) fn push_partial_blockrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]push_partial_block().(&mut self, partial: &'reg Templaterust-analyzer cargo handlebars 5.1.2 template/Template#) { |
| 187 | self.inner_mutrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner_mut().().partial_block_stackrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partial_block_stack..push_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]push_front().(partial); |
| 188 | } |
| 189 | |
| 190 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) fn pop_partial_blockrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]pop_partial_block().(&mut self) { |
| 191 | self.inner_mutrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner_mut().().partial_block_stackrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partial_block_stack..pop_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]pop_front().(); |
| 192 | } |
| 193 | |
| 194 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) fn inc_partial_block_depthrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inc_partial_block_depth().(&mut self) { |
| 195 | self.inner_mutrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner_mut().().partial_block_depthrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partial_block_depth. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`AddAssign<Self>`]add_assign().1; |
| 196 | } |
| 197 | |
| 198 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) fn dec_partial_block_depthrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]dec_partial_block_depth().(&mut self) { |
| 199 | let depth = &mut self.inner_mutrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner_mut().().partial_block_depthrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partial_block_depth.; |
| 200 | if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().depth rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]gt().0 { |
| 201 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().depth rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`SubAssign<Self>`]sub_assign().1; |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) fn set_indent_stringrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]set_indent_string().(&mut self, indent: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'reg Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) { |
| 206 | self.inner_mutrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner_mut().().indent_stringrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#indent_string. = indent; |
| 207 | } |
| 208 | |
| 209 | #[inline] |
| 210 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) fn get_indent_stringrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]get_indent_string().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'reg Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 211 | self.innerrust-analyzer cargo handlebars 5.1.2 render/RenderContext#inner..indent_stringrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#indent_string. |
| 212 | } |
| 213 | |
| 214 | /// Remove a registered partial |
| 215 | pub fn remove_partialrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]remove_partial().(&mut self, name: &str) { |
| 216 | self.inner_mutrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner_mut().().partialsrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partials..removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]remove().(name); |
| 217 | } |
| 218 | |
| 219 | fn get_local_varrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]get_local_var().(&self, level: usize, name: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Jsonrust-analyzer cargo serde_json 1.0.114 value/Value#> { |
| 220 | self.blocksrust-analyzer cargo handlebars 5.1.2 render/RenderContext#blocks. |
| 221 | .getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/vec_deque/impl#[`VecDeque<T, A>`]get().(level) |
| 222 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|blk| blk.get_local_varrust-analyzer cargo handlebars 5.1.2 block/impl#[`BlockContext<'rc>`]get_local_var().(name)) |
| 223 | } |
| 224 | |
| 225 | /// Test if given template name is current template. |
| 226 | pub fn is_current_templaterust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]is_current_template().(&self, p: &str) -> bool { |
| 227 | self.innerrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner().() |
| 228 | .current_templaterust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#current_template. |
| 229 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| s rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().p) |
| 230 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false) |
| 231 | } |
| 232 | |
| 233 | /// Register a helper in this render context. |
| 234 | /// This is a feature provided by Decorator where you can create |
| 235 | /// temporary helpers. |
| 236 | pub fn register_local_helperrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]register_local_helper().( |
| 237 | &mut self, |
| 238 | name: &str, |
| 239 | def: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn HelperDefrust-analyzer cargo handlebars 5.1.2 helpers/HelperDef# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'rc>, |
| 240 | ) { |
| 241 | self.inner_mutrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner_mut().() |
| 242 | .local_helpersrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#local_helpers. |
| 243 | .insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(name.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), def.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()); |
| 244 | } |
| 245 | |
| 246 | /// Remove a helper from render context |
| 247 | pub fn unregister_local_helperrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]unregister_local_helper().(&mut self, name: &str) { |
| 248 | self.inner_mutrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner_mut().().local_helpersrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#local_helpers..removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]remove().(name); |
| 249 | } |
| 250 | |
| 251 | /// Attempt to get a helper from current render context. |
| 252 | pub fn get_local_helperrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]get_local_helper().(&self, name: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<dyn HelperDefrust-analyzer cargo handlebars 5.1.2 helpers/HelperDef# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'rc>> { |
| 253 | self.innerrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner().().local_helpersrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#local_helpers..getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get().(name).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]cloned().() |
| 254 | } |
| 255 | |
| 256 | #[inline] |
| 257 | fn has_local_helperrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]has_local_helper().(&self, name: &str) -> bool { |
| 258 | self.innerrust-analyzer cargo handlebars 5.1.2 render/RenderContext#inner..local_helpersrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#local_helpers..contains_keyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]contains_key().(name) |
| 259 | } |
| 260 | |
| 261 | /// Returns the current template name. |
| 262 | /// Note that the name can be vary from root template when you are rendering |
| 263 | /// from partials. |
| 264 | pub fn get_current_template_namerust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]get_current_template_name().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'rc Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 265 | self.innerrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner().().current_templaterust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#current_template. |
| 266 | } |
| 267 | |
| 268 | /// Set the current template name. |
| 269 | pub fn set_current_template_namerust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]set_current_template_name().(&mut self, name: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'rc Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) { |
| 270 | self.inner_mutrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner_mut().().current_templaterust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#current_template. = name; |
| 271 | } |
| 272 | |
| 273 | /// Get root template name if any. |
| 274 | /// This is the template name that you call `render` from `Handlebars`. |
| 275 | pub fn get_root_template_namerust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]get_root_template_name().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'reg Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 276 | self.innerrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner().().root_templaterust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#root_template. |
| 277 | } |
| 278 | |
| 279 | /// Get the escape toggle |
| 280 | pub fn is_disable_escaperust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]is_disable_escape().(&self) -> bool { |
| 281 | self.innerrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner().().disable_escaperust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#disable_escape. |
| 282 | } |
| 283 | |
| 284 | /// Set the escape toggle. |
| 285 | /// When toggle is on, escape_fn will be called when rendering. |
| 286 | pub fn set_disable_escaperust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]set_disable_escape().(&mut self, disable: bool) { |
| 287 | self.inner_mutrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]inner_mut().().disable_escaperust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#disable_escape. = disable |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | impl<'reg, 'rc> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for RenderContextInnerrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#<'reg, 'rc> { |
| 292 | fn fmtrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContextInner<'reg, 'rc>`][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Error#> { |
| 293 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("RenderContextInner") |
| 294 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("partials", &self.partialsrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partials.) |
| 295 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("partial_block_stack", &self.partial_block_stackrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partial_block_stack.) |
| 296 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("partial_block_depth", &self.partial_block_depthrust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#partial_block_depth.) |
| 297 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("root_template", &self.root_templaterust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#root_template.) |
| 298 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("current_template", &self.current_templaterust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#current_template.) |
| 299 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("disable_escape", &self.disable_escaperust-analyzer cargo handlebars 5.1.2 render/RenderContextInner#disable_escape.) |
| 300 | .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().() |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | /// Render-time Helper data when using in a helper definition |
| 305 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 306 | pub struct Helperrust-analyzer cargo handlebars 5.1.2 render/Helper#<'rc> { |
| 307 | namerust-analyzer cargo handlebars 5.1.2 render/Helper#name.: Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'rc, str>, |
| 308 | paramsrust-analyzer cargo handlebars 5.1.2 render/Helper#params.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#<'rc>>, |
| 309 | hashrust-analyzer cargo handlebars 5.1.2 render/Helper#hash.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<&'rc str, PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#<'rc>>, |
| 310 | templaterust-analyzer cargo handlebars 5.1.2 render/Helper#template.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'rc Templaterust-analyzer cargo handlebars 5.1.2 template/Template#>, |
| 311 | inverserust-analyzer cargo handlebars 5.1.2 render/Helper#inverse.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'rc Templaterust-analyzer cargo handlebars 5.1.2 template/Template#>, |
| 312 | block_paramrust-analyzer cargo handlebars 5.1.2 render/Helper#block_param.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'rc BlockParamrust-analyzer cargo handlebars 5.1.2 template/BlockParam#>, |
| 313 | blockrust-analyzer cargo handlebars 5.1.2 render/Helper#block.: bool, |
| 314 | } |
| 315 | |
| 316 | impl<'reg: 'rc, 'rc> Helperrust-analyzer cargo handlebars 5.1.2 render/Helper#<'rc> { |
| 317 | fn try_from_templaterust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]try_from_template().( |
| 318 | ht: &'rc HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#, |
| 319 | registry: &'reg Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 320 | context: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 321 | render_context: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 322 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Helperrust-analyzer cargo handlebars 5.1.2 render/Helper#<'rc>, RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 323 | let name = ht.namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name..expand_as_namerust-analyzer cargo handlebars 5.1.2 render/impl#[Parameter]expand_as_name().(registry, context, render_context)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 324 | let mut pv = 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().(ht.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().()); |
| 325 | for p in &ht.paramsrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#params. { |
| 326 | let r = p.expandrust-analyzer cargo handlebars 5.1.2 render/impl#[Parameter]expand().(registry, context, render_context)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 327 | pv.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(r); |
| 328 | } |
| 329 | |
| 330 | let mut hm = BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 331 | for (k, p) in &ht.hashrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#hash. { |
| 332 | let r = p.expandrust-analyzer cargo handlebars 5.1.2 render/impl#[Parameter]expand().(registry, context, render_context)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 333 | hm.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(k.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AsRef<str>`]as_ref().(), r); |
| 334 | } |
| 335 | |
| 336 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Helperrust-analyzer cargo handlebars 5.1.2 render/Helper# { |
| 337 | namerust-analyzer cargo handlebars 5.1.2 render/Helper#name., |
| 338 | paramsrust-analyzer cargo handlebars 5.1.2 render/Helper#params.: pv, |
| 339 | hashrust-analyzer cargo handlebars 5.1.2 render/Helper#hash.: hm, |
| 340 | templaterust-analyzer cargo handlebars 5.1.2 render/Helper#template.: ht.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().(), |
| 341 | inverserust-analyzer cargo handlebars 5.1.2 render/Helper#inverse.: ht.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().(), |
| 342 | block_paramrust-analyzer cargo handlebars 5.1.2 render/Helper#block_param.: ht.block_paramrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block_param..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().(), |
| 343 | blockrust-analyzer cargo handlebars 5.1.2 render/Helper#block.: ht.blockrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block., |
| 344 | }) |
| 345 | } |
| 346 | |
| 347 | /// Returns helper name |
| 348 | pub fn namerust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]name().(&self) -> &str { |
| 349 | &self.namerust-analyzer cargo handlebars 5.1.2 render/Helper#name. |
| 350 | } |
| 351 | |
| 352 | /// Returns all helper params, resolved within the context |
| 353 | pub fn paramsrust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]params().(&self) -> &Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#<'rc>> { |
| 354 | &self.paramsrust-analyzer cargo handlebars 5.1.2 render/Helper#params. |
| 355 | } |
| 356 | |
| 357 | /// Returns nth helper param, resolved within the context. |
| 358 | /// |
| 359 | /// ## Example |
| 360 | /// |
| 361 | /// To get the first param in `{{my_helper abc}}` or `{{my_helper 2}}`, |
| 362 | /// use `h.param(0)` in helper definition. |
| 363 | /// Variable `abc` is auto resolved in current context. |
| 364 | /// |
| 365 | /// ``` |
| 366 | /// use handlebars::*; |
| 367 | /// |
| 368 | /// fn my_helper(h: &Helper, rc: &mut RenderContext) -> Result<(), RenderError> { |
| 369 | /// let v = h.param(0).map(|v| v.value()) |
| 370 | /// .ok_or(RenderErrorReason::ParamNotFoundForIndex("myhelper", 0)); |
| 371 | /// // .. |
| 372 | /// Ok(()) |
| 373 | /// } |
| 374 | /// ``` |
| 375 | pub fn paramrust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]param().(&self, idx: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#<'rc>> { |
| 376 | self.paramsrust-analyzer cargo handlebars 5.1.2 render/Helper#params..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(idx) |
| 377 | } |
| 378 | |
| 379 | /// Returns hash, resolved within the context |
| 380 | pub fn hashrust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]hash().(&self) -> &BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<&'rc str, PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#<'rc>> { |
| 381 | &self.hashrust-analyzer cargo handlebars 5.1.2 render/Helper#hash. |
| 382 | } |
| 383 | |
| 384 | /// Return hash value of a given key, resolved within the context |
| 385 | /// |
| 386 | /// ## Example |
| 387 | /// |
| 388 | /// To get the first param in `{{my_helper v=abc}}` or `{{my_helper v=2}}`, |
| 389 | /// use `h.hash_get("v")` in helper definition. |
| 390 | /// Variable `abc` is auto resolved in current context. |
| 391 | /// |
| 392 | /// ``` |
| 393 | /// use handlebars::*; |
| 394 | /// |
| 395 | /// fn my_helper(h: &Helper, rc: &mut RenderContext) -> Result<(), RenderError> { |
| 396 | /// let v = h.hash_get("v").map(|v| v.value()) |
| 397 | /// .ok_or(RenderErrorReason::ParamNotFoundForIndex("my_helper", 0)); |
| 398 | /// // .. |
| 399 | /// Ok(()) |
| 400 | /// } |
| 401 | /// ``` |
| 402 | pub fn hash_getrust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]hash_get().(&self, key: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#<'rc>> { |
| 403 | self.hashrust-analyzer cargo handlebars 5.1.2 render/Helper#hash..getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get().(key) |
| 404 | } |
| 405 | |
| 406 | /// Returns the default inner template if the helper is a block helper. |
| 407 | /// |
| 408 | /// Typically you will render the template via: `template.render(registry, render_context)` |
| 409 | /// |
| 410 | pub fn templaterust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]template().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'rc Templaterust-analyzer cargo handlebars 5.1.2 template/Template#> { |
| 411 | self.templaterust-analyzer cargo handlebars 5.1.2 render/Helper#template. |
| 412 | } |
| 413 | |
| 414 | /// Returns the template of `else` branch if any |
| 415 | pub fn inverserust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]inverse().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'rc Templaterust-analyzer cargo handlebars 5.1.2 template/Template#> { |
| 416 | self.inverserust-analyzer cargo handlebars 5.1.2 render/Helper#inverse. |
| 417 | } |
| 418 | |
| 419 | /// Returns if the helper is a block one `{{#helper}}{{/helper}}` or not `{{helper 123}}` |
| 420 | pub fn is_blockrust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]is_block().(&self) -> bool { |
| 421 | self.blockrust-analyzer cargo handlebars 5.1.2 render/Helper#block. |
| 422 | } |
| 423 | |
| 424 | /// Returns if the helper has either a block param or block param pair |
| 425 | pub fn has_block_paramrust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]has_block_param().(&self) -> bool { |
| 426 | self.block_paramrust-analyzer cargo handlebars 5.1.2 render/Helper#block_param..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() |
| 427 | } |
| 428 | |
| 429 | /// Returns block param if any |
| 430 | pub fn block_paramrust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]block_param().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'rc str> { |
| 431 | 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 s))) = self.block_paramrust-analyzer cargo handlebars 5.1.2 render/Helper#block_param. { |
| 432 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s) |
| 433 | } else { |
| 434 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | /// Return block param pair (for example |key, val|) if any |
| 439 | pub fn block_param_pairrust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]block_param_pair().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&'rc str, &'rc str)> { |
| 440 | 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#((Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#(ref s1), Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#(ref s2)))) = |
| 441 | self.block_paramrust-analyzer cargo handlebars 5.1.2 render/Helper#block_param. |
| 442 | { |
| 443 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((s1, s2)) |
| 444 | } else { |
| 445 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 446 | } |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | /// Render-time Decorator data when using in a decorator definition |
| 451 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 452 | pub struct Decoratorrust-analyzer cargo handlebars 5.1.2 render/Decorator#<'rc> { |
| 453 | namerust-analyzer cargo handlebars 5.1.2 render/Decorator#name.: Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'rc, str>, |
| 454 | paramsrust-analyzer cargo handlebars 5.1.2 render/Decorator#params.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#<'rc>>, |
| 455 | hashrust-analyzer cargo handlebars 5.1.2 render/Decorator#hash.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<&'rc str, PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#<'rc>>, |
| 456 | templaterust-analyzer cargo handlebars 5.1.2 render/Decorator#template.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'rc Templaterust-analyzer cargo handlebars 5.1.2 template/Template#>, |
| 457 | indentrust-analyzer cargo handlebars 5.1.2 render/Decorator#indent.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'rc Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 458 | } |
| 459 | |
| 460 | impl<'reg: 'rc, 'rc> Decoratorrust-analyzer cargo handlebars 5.1.2 render/Decorator#<'rc> { |
| 461 | fn try_from_templaterust-analyzer cargo handlebars 5.1.2 render/impl#[`Decorator<'rc>`]try_from_template().( |
| 462 | dt: &'rc DecoratorTemplaterust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#, |
| 463 | registry: &'reg Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 464 | context: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 465 | render_context: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 466 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Decoratorrust-analyzer cargo handlebars 5.1.2 render/Decorator#<'rc>, RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 467 | let name = dt.namerust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#name..expand_as_namerust-analyzer cargo handlebars 5.1.2 render/impl#[Parameter]expand_as_name().(registry, context, render_context)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 468 | |
| 469 | let mut pv = 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().(dt.paramsrust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#params..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()); |
| 470 | for p in &dt.paramsrust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#params. { |
| 471 | let r = p.expandrust-analyzer cargo handlebars 5.1.2 render/impl#[Parameter]expand().(registry, context, render_context)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 472 | pv.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(r); |
| 473 | } |
| 474 | |
| 475 | let mut hm = BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 476 | for (k, p) in &dt.hashrust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#hash. { |
| 477 | let r = p.expandrust-analyzer cargo handlebars 5.1.2 render/impl#[Parameter]expand().(registry, context, render_context)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 478 | hm.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(k.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AsRef<str>`]as_ref().(), r); |
| 479 | } |
| 480 | |
| 481 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Decoratorrust-analyzer cargo handlebars 5.1.2 render/Decorator# { |
| 482 | namerust-analyzer cargo handlebars 5.1.2 render/Decorator#name., |
| 483 | paramsrust-analyzer cargo handlebars 5.1.2 render/Decorator#params.: pv, |
| 484 | hashrust-analyzer cargo handlebars 5.1.2 render/Decorator#hash.: hm, |
| 485 | templaterust-analyzer cargo handlebars 5.1.2 render/Decorator#template.: dt.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().(), |
| 486 | indentrust-analyzer cargo handlebars 5.1.2 render/Decorator#indent.: dt.indentrust-analyzer cargo handlebars 5.1.2 template/DecoratorTemplate#indent..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().(), |
| 487 | }) |
| 488 | } |
| 489 | |
| 490 | /// Returns helper name |
| 491 | pub fn namerust-analyzer cargo handlebars 5.1.2 render/impl#[`Decorator<'rc>`]name().(&self) -> &str { |
| 492 | self.namerust-analyzer cargo handlebars 5.1.2 render/Decorator#name..as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().() |
| 493 | } |
| 494 | |
| 495 | /// Returns all helper params, resolved within the context |
| 496 | pub fn paramsrust-analyzer cargo handlebars 5.1.2 render/impl#[`Decorator<'rc>`]params().(&self) -> &Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#<'rc>> { |
| 497 | &self.paramsrust-analyzer cargo handlebars 5.1.2 render/Decorator#params. |
| 498 | } |
| 499 | |
| 500 | /// Returns nth helper param, resolved within the context |
| 501 | pub fn paramrust-analyzer cargo handlebars 5.1.2 render/impl#[`Decorator<'rc>`]param().(&self, idx: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#<'rc>> { |
| 502 | self.paramsrust-analyzer cargo handlebars 5.1.2 render/Decorator#params..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(idx) |
| 503 | } |
| 504 | |
| 505 | /// Returns hash, resolved within the context |
| 506 | pub fn hashrust-analyzer cargo handlebars 5.1.2 render/impl#[`Decorator<'rc>`]hash().(&self) -> &BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<&'rc str, PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#<'rc>> { |
| 507 | &self.hashrust-analyzer cargo handlebars 5.1.2 render/Decorator#hash. |
| 508 | } |
| 509 | |
| 510 | /// Return hash value of a given key, resolved within the context |
| 511 | pub fn hash_getrust-analyzer cargo handlebars 5.1.2 render/impl#[`Decorator<'rc>`]hash_get().(&self, key: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#<'rc>> { |
| 512 | self.hashrust-analyzer cargo handlebars 5.1.2 render/Decorator#hash..getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get().(key) |
| 513 | } |
| 514 | |
| 515 | /// Returns the default inner template if any |
| 516 | pub fn templaterust-analyzer cargo handlebars 5.1.2 render/impl#[`Decorator<'rc>`]template().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'rc Templaterust-analyzer cargo handlebars 5.1.2 template/Template#> { |
| 517 | self.templaterust-analyzer cargo handlebars 5.1.2 render/Decorator#template. |
| 518 | } |
| 519 | |
| 520 | pub fn indentrust-analyzer cargo handlebars 5.1.2 render/impl#[`Decorator<'rc>`]indent().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'rc Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 521 | self.indentrust-analyzer cargo handlebars 5.1.2 render/Decorator#indent. |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | /// Render trait |
| 526 | pub trait Renderablerust-analyzer cargo handlebars 5.1.2 render/Renderable# { |
| 527 | /// render into RenderContext's `writer` |
| 528 | fn renderrust-analyzer cargo handlebars 5.1.2 render/Renderable#render().<'reg: 'rc, 'rc>( |
| 529 | &'rc self, |
| 530 | registry: &'reg Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 531 | context: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 532 | rc: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 533 | out: &mut dyn Outputrust-analyzer cargo handlebars 5.1.2 output/Output#, |
| 534 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#>; |
| 535 | |
| 536 | /// render into string |
| 537 | fn rendersrust-analyzer cargo handlebars 5.1.2 render/Renderable#renders().<'reg: 'rc, 'rc>( |
| 538 | &'rc self, |
| 539 | registry: &'reg Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 540 | ctx: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 541 | rc: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 542 | ) -> 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#, RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 543 | let mut so = StringOutputrust-analyzer cargo handlebars 5.1.2 output/StringOutput#::newrust-analyzer cargo handlebars 5.1.2 output/impl#[StringOutput]new().(); |
| 544 | self.renderrust-analyzer cargo handlebars 5.1.2 render/Renderable#render().(registry, ctx, rc, &mut so)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 545 | so.into_stringrust-analyzer cargo handlebars 5.1.2 output/impl#[StringOutput]into_string().() |
| 546 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| RenderErrorReasonrust-analyzer cargo handlebars 5.1.2 error/RenderErrorReason#::fromrust-analyzer cargo handlebars 5.1.2 error/impl#[RenderErrorReason][`From<FromUtf8Error>`]from().(e).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | /// Evaluate decorator |
| 551 | pub trait Evaluablerust-analyzer cargo handlebars 5.1.2 render/Evaluable# { |
| 552 | fn evalrust-analyzer cargo handlebars 5.1.2 render/Evaluable#eval().<'reg: 'rc, 'rc>( |
| 553 | &'rc self, |
| 554 | registry: &'reg Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 555 | context: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 556 | rc: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 557 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#>; |
| 558 | } |
| 559 | |
| 560 | #[inline] |
| 561 | fn call_helper_for_valuerust-analyzer cargo handlebars 5.1.2 render/call_helper_for_value().<'reg: 'rc, 'rc>( |
| 562 | hd: &dyn HelperDefrust-analyzer cargo handlebars 5.1.2 helpers/HelperDef#, |
| 563 | ht: &Helperrust-analyzer cargo handlebars 5.1.2 render/Helper#<'rc>, |
| 564 | r: &'reg Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 565 | ctx: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 566 | rc: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 567 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#<'rc>, RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 568 | match hd.call_innerrust-analyzer cargo handlebars 5.1.2 helpers/HelperDef#call_inner().(ht, r, ctx, rc) { |
| 569 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(result) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#::newrust-analyzer cargo handlebars 5.1.2 json/value/impl#[`PathAndJson<'rc>`]new().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, result)), |
| 570 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => { |
| 571 | if e.is_unimplementedrust-analyzer cargo handlebars 5.1.2 error/impl#[RenderError]is_unimplemented().() { |
| 572 | // parse value from output |
| 573 | let mut so = StringOutputrust-analyzer cargo handlebars 5.1.2 output/StringOutput#::newrust-analyzer cargo handlebars 5.1.2 output/impl#[StringOutput]new().(); |
| 574 | |
| 575 | // here we don't want subexpression result escaped, |
| 576 | // so we temporarily disable it |
| 577 | let disable_escape = rc.is_disable_escaperust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]is_disable_escape().(); |
| 578 | rc.set_disable_escaperust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]set_disable_escape().(true); |
| 579 | |
| 580 | hd.callrust-analyzer cargo handlebars 5.1.2 helpers/HelperDef#call().(ht, r, ctx, rc, &mut so)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 581 | rc.set_disable_escaperust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]set_disable_escape().(disable_escape); |
| 582 | |
| 583 | let string = so.into_stringrust-analyzer cargo handlebars 5.1.2 output/impl#[StringOutput]into_string().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#::fromrust-analyzer cargo handlebars 5.1.2 error/impl#[RenderError][`From<FromUtf8Error>`]from().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 584 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#::newrust-analyzer cargo handlebars 5.1.2 json/value/impl#[`PathAndJson<'rc>`]new().( |
| 585 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 586 | ScopedJsonrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#::Derivedrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#Derived#(Jsonrust-analyzer cargo serde_json 1.0.114 value/Value#::Stringrust-analyzer cargo serde_json 1.0.114 value/Value#String#(string)), |
| 587 | )) |
| 588 | } else { |
| 589 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) |
| 590 | } |
| 591 | } |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | impl Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter# { |
| 596 | pub fn expand_as_namerust-analyzer cargo handlebars 5.1.2 render/impl#[Parameter]expand_as_name().<'reg: 'rc, 'rc>( |
| 597 | &'rc self, |
| 598 | registry: &'reg Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 599 | ctx: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 600 | rc: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 601 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'rc, str>, RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 602 | match self { |
| 603 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#(ref name) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#(name)), |
| 604 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Pathrust-analyzer cargo handlebars 5.1.2 template/Parameter#Path#(ref p) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#(p.rawrust-analyzer cargo handlebars 5.1.2 json/path/impl#[Path]raw().())), |
| 605 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Subexpressionrust-analyzer cargo handlebars 5.1.2 template/Parameter#Subexpression#(_) => self |
| 606 | .expandrust-analyzer cargo handlebars 5.1.2 render/impl#[Parameter]expand().(registry, ctx, rc) |
| 607 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|v| v.valuerust-analyzer cargo handlebars 5.1.2 json/value/impl#[`PathAndJson<'rc>`]value().().renderrust-analyzer cargo handlebars 5.1.2 json/value/impl#[Json][JsonRender]render().()) |
| 608 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#), |
| 609 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Literalrust-analyzer cargo handlebars 5.1.2 template/Parameter#Literal#(ref j) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(j.renderrust-analyzer cargo handlebars 5.1.2 json/value/impl#[Json][JsonRender]render().())), |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | pub fn expandrust-analyzer cargo handlebars 5.1.2 render/impl#[Parameter]expand().<'reg: 'rc, 'rc>( |
| 614 | &'rc self, |
| 615 | registry: &'reg Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 616 | ctx: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 617 | rc: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 618 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#<'rc>, RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 619 | match self { |
| 620 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Namerust-analyzer cargo handlebars 5.1.2 template/Parameter#Name#(ref name) => { |
| 621 | // FIXME: raise error when expanding with name? |
| 622 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#::newrust-analyzer cargo handlebars 5.1.2 json/value/impl#[`PathAndJson<'rc>`]new().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(name.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[T][ToOwned]to_owned().()), ScopedJsonrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#::Missingrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#Missing#)) |
| 623 | } |
| 624 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Pathrust-analyzer cargo handlebars 5.1.2 template/Parameter#Path#(ref path) => { |
| 625 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rc_context) = rc.contextrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]context().() { |
| 626 | let result = rc.evaluate2rust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]evaluate2().(rc_context.borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][`Borrow<T>`]borrow().(), path)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 627 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#::newrust-analyzer cargo handlebars 5.1.2 json/value/impl#[`PathAndJson<'rc>`]new().( |
| 628 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(path.rawrust-analyzer cargo handlebars 5.1.2 json/path/impl#[Path]raw().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), |
| 629 | ScopedJsonrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#::Derivedrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#Derived#(result.as_jsonrust-analyzer cargo handlebars 5.1.2 json/value/impl#[`ScopedJson<'rc>`]as_json().().clonerust-analyzer cargo serde_json 1.0.114 value/impl#[Value][Clone]clone().()), |
| 630 | )) |
| 631 | } else { |
| 632 | let result = rc.evaluate2rust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]evaluate2().(ctx, path)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 633 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#::newrust-analyzer cargo handlebars 5.1.2 json/value/impl#[`PathAndJson<'rc>`]new().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(path.rawrust-analyzer cargo handlebars 5.1.2 json/path/impl#[Path]raw().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), result)) |
| 634 | } |
| 635 | } |
| 636 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Literalrust-analyzer cargo handlebars 5.1.2 template/Parameter#Literal#(ref j) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PathAndJsonrust-analyzer cargo handlebars 5.1.2 json/value/PathAndJson#::newrust-analyzer cargo handlebars 5.1.2 json/value/impl#[`PathAndJson<'rc>`]new().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, ScopedJsonrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#::Constantrust-analyzer cargo handlebars 5.1.2 json/value/ScopedJson#Constant#(j))), |
| 637 | Parameterrust-analyzer cargo handlebars 5.1.2 template/Parameter#::Subexpressionrust-analyzer cargo handlebars 5.1.2 template/Parameter#Subexpression#(ref t) => match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t.as_elementrust-analyzer cargo handlebars 5.1.2 template/impl#[Subexpression]as_element().() { |
| 638 | Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(ref ht) => { |
| 639 | let name = ht.namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name..expand_as_namerust-analyzer cargo handlebars 5.1.2 render/impl#[Parameter]expand_as_name().(registry, ctx, rc)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 640 | |
| 641 | let h = Helperrust-analyzer cargo handlebars 5.1.2 render/Helper#::try_from_templaterust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]try_from_template().(ht, registry, ctx, rc)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 642 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref d) = rc.get_local_helperrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]get_local_helper().(&name) { |
| 643 | call_helper_for_valuerust-analyzer cargo handlebars 5.1.2 render/call_helper_for_value().(d.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][`AsRef<T>`]as_ref().(), &h, registry, ctx, rc) |
| 644 | } else { |
| 645 | let mut helper = registry.get_or_load_helperrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]get_or_load_helper().(&name)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 646 | |
| 647 | if helper.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 648 | helper = registry.get_or_load_helperrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]get_or_load_helper().(if ht.blockrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block. { |
| 649 | BLOCK_HELPER_MISSINGrust-analyzer cargo handlebars 5.1.2 render/BLOCK_HELPER_MISSING. |
| 650 | } else { |
| 651 | HELPER_MISSINGrust-analyzer cargo handlebars 5.1.2 render/HELPER_MISSING. |
| 652 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 653 | } |
| 654 | |
| 655 | helper |
| 656 | .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| { |
| 657 | RenderErrorReasonrust-analyzer cargo handlebars 5.1.2 error/RenderErrorReason#::HelperNotFoundrust-analyzer cargo handlebars 5.1.2 error/RenderErrorReason#HelperNotFound#(name.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 658 | }) |
| 659 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(|d| call_helper_for_valuerust-analyzer cargo handlebars 5.1.2 render/call_helper_for_value().(d.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`AsRef<T>`]as_ref().(), &h, registry, ctx, rc)) |
| 660 | } |
| 661 | } |
| 662 | _ => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 663 | }, |
| 664 | } |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | impl Renderablerust-analyzer cargo handlebars 5.1.2 render/Renderable# for Templaterust-analyzer cargo handlebars 5.1.2 template/Template# { |
| 669 | fn renderrust-analyzer cargo handlebars 5.1.2 render/impl#[Template][Renderable]render().<'reg: 'rc, 'rc>( |
| 670 | &'rc self, |
| 671 | registry: &'reg Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 672 | ctx: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 673 | rc: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 674 | out: &mut dyn Outputrust-analyzer cargo handlebars 5.1.2 output/Output#, |
| 675 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 676 | rc.set_current_template_namerust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]set_current_template_name().(self.namerust-analyzer cargo handlebars 5.1.2 template/Template#name..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()); |
| 677 | let iter = self.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(); |
| 678 | |
| 679 | for (idx, t) in iter.enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 680 | t.renderrust-analyzer cargo handlebars 5.1.2 render/impl#[TemplateElement][Renderable]render().(registry, ctx, rc, out).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|mut e| { |
| 681 | // add line/col number if the template has mapping data |
| 682 | if e.line_norust-analyzer cargo handlebars 5.1.2 error/RenderError#line_no..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 683 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&TemplateMappingrust-analyzer cargo handlebars 5.1.2 template/TemplateMapping#(line, col)) = self.mappingrust-analyzer cargo handlebars 5.1.2 template/Template#mapping..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(idx) { |
| 684 | e.line_norust-analyzer cargo handlebars 5.1.2 error/RenderError#line_no. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(line); |
| 685 | e.column_norust-analyzer cargo handlebars 5.1.2 error/RenderError#column_no. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(col); |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | if e.template_namerust-analyzer cargo handlebars 5.1.2 error/RenderError#template_name..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 690 | e.template_namerust-analyzer cargo handlebars 5.1.2 error/RenderError#template_name..clone_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone_from().(&self.namerust-analyzer cargo handlebars 5.1.2 template/Template#name.); |
| 691 | } |
| 692 | |
| 693 | e |
| 694 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 695 | } |
| 696 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | impl Evaluablerust-analyzer cargo handlebars 5.1.2 render/Evaluable# for Templaterust-analyzer cargo handlebars 5.1.2 template/Template# { |
| 701 | fn evalrust-analyzer cargo handlebars 5.1.2 render/impl#[Template][Evaluable]eval().<'reg: 'rc, 'rc>( |
| 702 | &'rc self, |
| 703 | registry: &'reg Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 704 | ctx: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 705 | rc: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 706 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 707 | let iter = self.elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(); |
| 708 | |
| 709 | for (idx, t) in iter.enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 710 | t.evalrust-analyzer cargo handlebars 5.1.2 render/impl#[TemplateElement][Evaluable]eval().(registry, ctx, rc).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|mut e| { |
| 711 | if e.line_norust-analyzer cargo handlebars 5.1.2 error/RenderError#line_no..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 712 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&TemplateMappingrust-analyzer cargo handlebars 5.1.2 template/TemplateMapping#(line, col)) = self.mappingrust-analyzer cargo handlebars 5.1.2 template/Template#mapping..getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(idx) { |
| 713 | e.line_norust-analyzer cargo handlebars 5.1.2 error/RenderError#line_no. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(line); |
| 714 | e.column_norust-analyzer cargo handlebars 5.1.2 error/RenderError#column_no. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(col); |
| 715 | } |
| 716 | } |
| 717 | |
| 718 | e.template_namerust-analyzer cargo handlebars 5.1.2 error/RenderError#template_name..clone_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone_from().(&self.namerust-analyzer cargo handlebars 5.1.2 template/Template#name.); |
| 719 | e |
| 720 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 721 | } |
| 722 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | fn helper_existsrust-analyzer cargo handlebars 5.1.2 render/helper_exists().<'reg: 'rc, 'rc>( |
| 727 | name: &str, |
| 728 | reg: &Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 729 | rc: &RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 730 | ) -> bool { |
| 731 | rc.has_local_helperrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]has_local_helper().(name) || reg.has_helperrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]has_helper().(name) |
| 732 | } |
| 733 | |
| 734 | #[inline] |
| 735 | fn render_helperrust-analyzer cargo handlebars 5.1.2 render/render_helper().<'reg: 'rc, 'rc>( |
| 736 | ht: &'rc HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#, |
| 737 | registry: &'reg Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 738 | ctx: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 739 | rc: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 740 | out: &mut dyn Outputrust-analyzer cargo handlebars 5.1.2 output/Output#, |
| 741 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 742 | let h = Helperrust-analyzer cargo handlebars 5.1.2 render/Helper#::try_from_templaterust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]try_from_template().(ht, registry, ctx, rc)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 743 | debugrust-analyzer cargo handlebars 5.1.2 macros/logging/debug!!( |
| 744 | "Rendering helper: {:?}, params: {:?}, hash: {:?}", |
| 745 | h.name(), |
| 746 | h.params(), |
| 747 | h.hash() |
| 748 | ); |
| 749 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref d) = rc.get_local_helperrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]get_local_helper().(h.namerust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]name().()) { |
| 750 | d.callrust-analyzer cargo handlebars 5.1.2 helpers/HelperDef#call().(&h, registry, ctx, rc, out) |
| 751 | } else { |
| 752 | let mut helper = registry.get_or_load_helperrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]get_or_load_helper().(h.namerust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]name().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 753 | |
| 754 | if helper.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { |
| 755 | helper = registry.get_or_load_helperrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]get_or_load_helper().(if ht.blockrust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#block. { |
| 756 | BLOCK_HELPER_MISSINGrust-analyzer cargo handlebars 5.1.2 render/BLOCK_HELPER_MISSING. |
| 757 | } else { |
| 758 | HELPER_MISSINGrust-analyzer cargo handlebars 5.1.2 render/HELPER_MISSING. |
| 759 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 760 | } |
| 761 | |
| 762 | helper |
| 763 | .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| RenderErrorReasonrust-analyzer cargo handlebars 5.1.2 error/RenderErrorReason#::HelperNotFoundrust-analyzer cargo handlebars 5.1.2 error/RenderErrorReason#HelperNotFound#(h.namerust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]name().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 764 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(|d| d.callrust-analyzer cargo handlebars 5.1.2 helpers/HelperDef#call().(&h, registry, ctx, rc, out)) |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | pub(craterust-analyzer cargo handlebars 5.1.2 crate/) fn do_escaperust-analyzer cargo handlebars 5.1.2 render/do_escape().(r: &Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'_>, rc: &RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'_, '_>, content: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 769 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().rc.is_disable_escaperust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]is_disable_escape().() { |
| 770 | r.get_escape_fnrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]get_escape_fn().()(&content) |
| 771 | } else { |
| 772 | content |
| 773 | } |
| 774 | } |
| 775 | |
| 776 | #[inline] |
| 777 | fn indent_aware_writerust-analyzer cargo handlebars 5.1.2 render/indent_aware_write().( |
| 778 | v: &str, |
| 779 | rc: &RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'_, '_>, |
| 780 | out: &mut dyn Outputrust-analyzer cargo handlebars 5.1.2 output/Output#, |
| 781 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 782 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(indent) = rc.get_indent_stringrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]get_indent_string().() { |
| 783 | out.writerust-analyzer cargo handlebars 5.1.2 output/Output#write().(supportrust-analyzer cargo handlebars 5.1.2 support/::strrust-analyzer cargo handlebars 5.1.2 support/str/::with_indentrust-analyzer cargo handlebars 5.1.2 support/str/with_indent().(v, indent).as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AsRef<str>`]as_ref().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 784 | } else { |
| 785 | out.writerust-analyzer cargo handlebars 5.1.2 output/Output#write().(v.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[str][`AsRef<Self>`]as_ref().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 786 | } |
| 787 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 788 | } |
| 789 | |
| 790 | impl Renderablerust-analyzer cargo handlebars 5.1.2 render/Renderable# for TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement# { |
| 791 | fn renderrust-analyzer cargo handlebars 5.1.2 render/impl#[TemplateElement][Renderable]render().<'reg: 'rc, 'rc>( |
| 792 | &'rc self, |
| 793 | registry: &'reg Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 794 | ctx: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 795 | rc: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 796 | out: &mut dyn Outputrust-analyzer cargo handlebars 5.1.2 output/Output#, |
| 797 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 798 | match self { |
| 799 | RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#(ref v) => indent_aware_writerust-analyzer cargo handlebars 5.1.2 render/indent_aware_write().(v.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AsRef<str>`]as_ref().(), rc, out), |
| 800 | Expressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Expression#(ref ht) | HtmlExpressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HtmlExpression#(ref ht) => { |
| 801 | let is_html_expression = matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, HtmlExpressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HtmlExpression#(_)); |
| 802 | if is_html_expression { |
| 803 | rc.set_disable_escaperust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]set_disable_escape().(true); |
| 804 | } |
| 805 | |
| 806 | // test if the expression is to render some value |
| 807 | let result = if ht.is_name_onlyrust-analyzer cargo handlebars 5.1.2 template/impl#[HelperTemplate]is_name_only().() { |
| 808 | let helper_name = ht.namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name..expand_as_namerust-analyzer cargo handlebars 5.1.2 render/impl#[Parameter]expand_as_name().(registry, ctx, rc)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 809 | if helper_existsrust-analyzer cargo handlebars 5.1.2 render/helper_exists().(&helper_name, registry, rc) { |
| 810 | render_helperrust-analyzer cargo handlebars 5.1.2 render/render_helper().(ht, registry, ctx, rc, out) |
| 811 | } else { |
| 812 | debugrust-analyzer cargo handlebars 5.1.2 macros/logging/debug!!("Rendering value: {:?}", ht.name); |
| 813 | let context_json = ht.namerust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#name..expandrust-analyzer cargo handlebars 5.1.2 render/impl#[Parameter]expand().(registry, ctx, rc)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 814 | if context_json.is_value_missingrust-analyzer cargo handlebars 5.1.2 json/value/impl#[`PathAndJson<'rc>`]is_value_missing().() { |
| 815 | if registry.strict_moderust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]strict_mode().() { |
| 816 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#::strict_errorrust-analyzer cargo handlebars 5.1.2 error/impl#[RenderError]strict_error().(context_json.relative_pathrust-analyzer cargo handlebars 5.1.2 json/value/impl#[`PathAndJson<'rc>`]relative_path().())) |
| 817 | } else { |
| 818 | // helper missing |
| 819 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(hook) = registry.get_or_load_helperrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]get_or_load_helper().(HELPER_MISSINGrust-analyzer cargo handlebars 5.1.2 render/HELPER_MISSING.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). { |
| 820 | let h = Helperrust-analyzer cargo handlebars 5.1.2 render/Helper#::try_from_templaterust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]try_from_template().(ht, registry, ctx, rc)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 821 | hook.callrust-analyzer cargo handlebars 5.1.2 helpers/HelperDef#call().(&h, registry, ctx, rc, out) |
| 822 | } else { |
| 823 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 824 | } |
| 825 | } |
| 826 | } else { |
| 827 | let rendered = context_json.valuerust-analyzer cargo handlebars 5.1.2 json/value/impl#[`PathAndJson<'rc>`]value().().renderrust-analyzer cargo handlebars 5.1.2 json/value/impl#[Json][JsonRender]render().(); |
| 828 | let output = do_escaperust-analyzer cargo handlebars 5.1.2 render/do_escape().(registry, rc, rendered); |
| 829 | indent_aware_writerust-analyzer cargo handlebars 5.1.2 render/indent_aware_write().(output.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`AsRef<str>`]as_ref().(), rc, out) |
| 830 | } |
| 831 | } |
| 832 | } else { |
| 833 | // this is a helper expression |
| 834 | render_helperrust-analyzer cargo handlebars 5.1.2 render/render_helper().(ht, registry, ctx, rc, out) |
| 835 | }; |
| 836 | |
| 837 | if is_html_expression { |
| 838 | rc.set_disable_escaperust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]set_disable_escape().(false); |
| 839 | } |
| 840 | |
| 841 | result |
| 842 | } |
| 843 | HelperBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#HelperBlock#(ref ht) => render_helperrust-analyzer cargo handlebars 5.1.2 render/render_helper().(ht, registry, ctx, rc, out), |
| 844 | DecoratorExpressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#DecoratorExpression#(_) | DecoratorBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#DecoratorBlock#(_) => self.evalrust-analyzer cargo handlebars 5.1.2 render/impl#[TemplateElement][Evaluable]eval().(registry, ctx, rc), |
| 845 | PartialExpressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#PartialExpression#(ref dt) | PartialBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#PartialBlock#(ref dt) => { |
| 846 | let di = Decoratorrust-analyzer cargo handlebars 5.1.2 render/Decorator#::try_from_templaterust-analyzer cargo handlebars 5.1.2 render/impl#[`Decorator<'rc>`]try_from_template().(dt, registry, ctx, rc)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 847 | |
| 848 | partialrust-analyzer cargo handlebars 5.1.2 partial/::expand_partialrust-analyzer cargo handlebars 5.1.2 partial/expand_partial().(&di, registry, ctx, rc, out) |
| 849 | } |
| 850 | _ => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()), |
| 851 | } |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | impl Evaluablerust-analyzer cargo handlebars 5.1.2 render/Evaluable# for TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement# { |
| 856 | fn evalrust-analyzer cargo handlebars 5.1.2 render/impl#[TemplateElement][Evaluable]eval().<'reg: 'rc, 'rc>( |
| 857 | &'rc self, |
| 858 | registry: &'reg Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'reg>, |
| 859 | ctx: &'rc Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 860 | rc: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'reg, 'rc>, |
| 861 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 862 | match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self { |
| 863 | DecoratorExpressionrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#DecoratorExpression#(ref dt) | DecoratorBlockrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#DecoratorBlock#(ref dt) => { |
| 864 | let di = Decoratorrust-analyzer cargo handlebars 5.1.2 render/Decorator#::try_from_templaterust-analyzer cargo handlebars 5.1.2 render/impl#[`Decorator<'rc>`]try_from_template().(dt, registry, ctx, rc)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 865 | match registry.get_decoratorrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]get_decorator().(di.namerust-analyzer cargo handlebars 5.1.2 render/impl#[`Decorator<'rc>`]name().()) { |
| 866 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(d) => d.callrust-analyzer cargo handlebars 5.1.2 decorators/DecoratorDef#call().(&di, registry, ctx, rc), |
| 867 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(RenderErrorReasonrust-analyzer cargo handlebars 5.1.2 error/RenderErrorReason#::DecoratorNotFoundrust-analyzer cargo handlebars 5.1.2 error/RenderErrorReason#DecoratorNotFound#(di.namerust-analyzer cargo handlebars 5.1.2 render/impl#[`Decorator<'rc>`]name().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 868 | } |
| 869 | } |
| 870 | _ => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()), |
| 871 | } |
| 872 | } |
| 873 | } |
| 874 | |
| 875 | #[cfg(test)] |
| 876 | mod testrust-analyzer cargo handlebars 5.1.2 render/test/ { |
| 877 | 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/::BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#; |
| 878 | |
| 879 | use superrust-analyzer cargo handlebars 5.1.2 render/::{Helperrust-analyzer cargo handlebars 5.1.2 render/Helper#, RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#, Renderablerust-analyzer cargo handlebars 5.1.2 render/Renderable#}; |
| 880 | use craterust-analyzer cargo handlebars 5.1.2 crate/::blockrust-analyzer cargo handlebars 5.1.2 block/::BlockContextrust-analyzer cargo handlebars 5.1.2 block/BlockContext#; |
| 881 | use craterust-analyzer cargo handlebars 5.1.2 crate/::contextrust-analyzer cargo handlebars 5.1.2 context/::Contextrust-analyzer cargo handlebars 5.1.2 context/Context#; |
| 882 | use craterust-analyzer cargo handlebars 5.1.2 crate/::errorrust-analyzer cargo handlebars 5.1.2 error/::RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#; |
| 883 | 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/::Pathrust-analyzer cargo handlebars 5.1.2 json/path/Path#; |
| 884 | use craterust-analyzer cargo handlebars 5.1.2 crate/::jsonrust-analyzer cargo handlebars 5.1.2 json/::valuerust-analyzer cargo handlebars 5.1.2 json/value/::JsonRenderrust-analyzer cargo handlebars 5.1.2 json/value/JsonRender#; |
| 885 | use craterust-analyzer cargo handlebars 5.1.2 crate/::outputrust-analyzer cargo handlebars 5.1.2 output/::{Outputrust-analyzer cargo handlebars 5.1.2 output/Output#, StringOutputrust-analyzer cargo handlebars 5.1.2 output/StringOutput#}; |
| 886 | use craterust-analyzer cargo handlebars 5.1.2 crate/::registryrust-analyzer cargo handlebars 5.1.2 registry/::Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#; |
| 887 | use craterust-analyzer cargo handlebars 5.1.2 crate/::templaterust-analyzer cargo handlebars 5.1.2 template/::TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#::*; |
| 888 | use craterust-analyzer cargo handlebars 5.1.2 crate/::templaterust-analyzer cargo handlebars 5.1.2 template/::{HelperTemplaterust-analyzer cargo handlebars 5.1.2 template/HelperTemplate#, Templaterust-analyzer cargo handlebars 5.1.2 template/Template#, TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#}; |
| 889 | |
| 890 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 891 | fn test_raw_stringrust-analyzer cargo handlebars 5.1.2 render/test/test_raw_string().() { |
| 892 | let r = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 893 | let raw_string = RawStringrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#RawString#("<h1>hello world</h1>".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 894 | |
| 895 | let mut out = StringOutputrust-analyzer cargo handlebars 5.1.2 output/StringOutput#::newrust-analyzer cargo handlebars 5.1.2 output/impl#[StringOutput]new().(); |
| 896 | let ctx = Contextrust-analyzer cargo handlebars 5.1.2 context/Context#::nullrust-analyzer cargo handlebars 5.1.2 context/impl#[Context]null().(); |
| 897 | { |
| 898 | let mut rc = RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#::newrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]new().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 899 | raw_string.renderrust-analyzer cargo handlebars 5.1.2 render/impl#[TemplateElement][Renderable]render().(&r, &ctx, &mut rc, &mut out).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().(); |
| 900 | } |
| 901 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 902 | out.into_stringrust-analyzer cargo handlebars 5.1.2 output/impl#[StringOutput]into_string().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 903 | "<h1>hello world</h1>".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 904 | ); |
| 905 | } |
| 906 | |
| 907 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 908 | fn test_expressionrust-analyzer cargo handlebars 5.1.2 render/test/test_expression().() { |
| 909 | let r = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 910 | let element = 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().( |
| 911 | &["hello"], |
| 912 | )))); |
| 913 | |
| 914 | let mut out = StringOutputrust-analyzer cargo handlebars 5.1.2 output/StringOutput#::newrust-analyzer cargo handlebars 5.1.2 output/impl#[StringOutput]new().(); |
| 915 | let mut m: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 916 | let value = "<p></p>".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 917 | m.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().("hello".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), value); |
| 918 | let ctx = Contextrust-analyzer cargo handlebars 5.1.2 context/Context#::wrapsrust-analyzer cargo handlebars 5.1.2 context/impl#[Context]wraps().(&m).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 919 | { |
| 920 | let mut rc = RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#::newrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]new().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 921 | element.renderrust-analyzer cargo handlebars 5.1.2 render/impl#[TemplateElement][Renderable]render().(&r, &ctx, &mut rc, &mut out).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().(); |
| 922 | } |
| 923 | |
| 924 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 925 | out.into_stringrust-analyzer cargo handlebars 5.1.2 output/impl#[StringOutput]into_string().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 926 | "<p></p>".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 927 | ); |
| 928 | } |
| 929 | |
| 930 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 931 | fn test_html_expressionrust-analyzer cargo handlebars 5.1.2 render/test/test_html_expression().() { |
| 932 | let r = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 933 | let element = 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().( |
| 934 | &["hello"], |
| 935 | )))); |
| 936 | |
| 937 | let mut out = StringOutputrust-analyzer cargo handlebars 5.1.2 output/StringOutput#::newrust-analyzer cargo handlebars 5.1.2 output/impl#[StringOutput]new().(); |
| 938 | let mut m: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 939 | let value = "world"; |
| 940 | m.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().("hello".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), value.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 941 | let ctx = Contextrust-analyzer cargo handlebars 5.1.2 context/Context#::wrapsrust-analyzer cargo handlebars 5.1.2 context/impl#[Context]wraps().(&m).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 942 | { |
| 943 | let mut rc = RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#::newrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]new().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 944 | element.renderrust-analyzer cargo handlebars 5.1.2 render/impl#[TemplateElement][Renderable]render().(&r, &ctx, &mut rc, &mut out).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().(); |
| 945 | } |
| 946 | |
| 947 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(out.into_stringrust-analyzer cargo handlebars 5.1.2 output/impl#[StringOutput]into_string().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), value.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 948 | } |
| 949 | |
| 950 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 951 | fn test_templaterust-analyzer cargo handlebars 5.1.2 render/test/test_template().() { |
| 952 | let r = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 953 | let mut out = StringOutputrust-analyzer cargo handlebars 5.1.2 output/StringOutput#::newrust-analyzer cargo handlebars 5.1.2 output/impl#[StringOutput]new().(); |
| 954 | let mut m: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 955 | let value = "world".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 956 | m.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().("hello".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), value); |
| 957 | let ctx = Contextrust-analyzer cargo handlebars 5.1.2 context/Context#::wrapsrust-analyzer cargo handlebars 5.1.2 context/impl#[Context]wraps().(&m).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 958 | |
| 959 | let elements: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<TemplateElementrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 960 | 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().()), |
| 961 | 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().( |
| 962 | &["hello"], |
| 963 | )))), |
| 964 | 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().()), |
| 965 | Commentrust-analyzer cargo handlebars 5.1.2 template/TemplateElement#Comment#("".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 966 | ]; |
| 967 | |
| 968 | let template = Templaterust-analyzer cargo handlebars 5.1.2 template/Template# { |
| 969 | elementsrust-analyzer cargo handlebars 5.1.2 template/Template#elements., |
| 970 | namerust-analyzer cargo handlebars 5.1.2 template/Template#name.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 971 | mappingrust-analyzer cargo handlebars 5.1.2 template/Template#mapping.: 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().(), |
| 972 | }; |
| 973 | |
| 974 | { |
| 975 | let mut rc = RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#::newrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]new().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 976 | template.renderrust-analyzer cargo handlebars 5.1.2 render/impl#[Template][Renderable]render().(&r, &ctx, &mut rc, &mut out).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().(); |
| 977 | } |
| 978 | |
| 979 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(out.into_stringrust-analyzer cargo handlebars 5.1.2 output/impl#[StringOutput]into_string().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "<h1>world</h1>".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 980 | } |
| 981 | |
| 982 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 983 | fn test_render_context_promotion_and_demotionrust-analyzer cargo handlebars 5.1.2 render/test/test_render_context_promotion_and_demotion().() { |
| 984 | use craterust-analyzer cargo handlebars 5.1.2 crate/::jsonrust-analyzer cargo handlebars 5.1.2 json/::valuerust-analyzer cargo handlebars 5.1.2 json/value/::to_jsonrust-analyzer cargo handlebars 5.1.2 json/value/to_json().; |
| 985 | let mut render_context = RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#::newrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]new().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 986 | let mut block = BlockContextrust-analyzer cargo handlebars 5.1.2 block/BlockContext#::newrust-analyzer cargo handlebars 5.1.2 block/impl#[`BlockContext<'rc>`]new().(); |
| 987 | |
| 988 | block.set_local_varrust-analyzer cargo handlebars 5.1.2 block/impl#[`BlockContext<'rc>`]set_local_var().("index", to_jsonrust-analyzer cargo handlebars 5.1.2 json/value/to_json().(0)); |
| 989 | render_context.push_blockrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]push_block().(block); |
| 990 | |
| 991 | render_context.push_blockrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]push_block().(BlockContextrust-analyzer cargo handlebars 5.1.2 block/BlockContext#::newrust-analyzer cargo handlebars 5.1.2 block/impl#[`BlockContext<'rc>`]new().()); |
| 992 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 993 | render_context.get_local_varrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]get_local_var().(1, "index").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 994 | &to_jsonrust-analyzer cargo handlebars 5.1.2 json/value/to_json().(0) |
| 995 | ); |
| 996 | |
| 997 | render_context.pop_blockrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]pop_block().(); |
| 998 | |
| 999 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1000 | render_context.get_local_varrust-analyzer cargo handlebars 5.1.2 render/impl#[`RenderContext<'reg, 'rc>`]get_local_var().(0, "index").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 1001 | &to_jsonrust-analyzer cargo handlebars 5.1.2 json/value/to_json().(0) |
| 1002 | ); |
| 1003 | } |
| 1004 | |
| 1005 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1006 | fn test_render_subexpression_issue_115rust-analyzer cargo handlebars 5.1.2 render/test/test_render_subexpression_issue_115().() { |
| 1007 | use craterust-analyzer cargo handlebars 5.1.2 crate/::supportrust-analyzer cargo handlebars 5.1.2 support/::strrust-analyzer cargo handlebars 5.1.2 support/str/::StringWriterrust-analyzer cargo handlebars 5.1.2 support/str/StringWriter#; |
| 1008 | |
| 1009 | let mut r = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 1010 | r.register_helperrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_helper().( |
| 1011 | "format", |
| 1012 | 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().( |
| 1013 | |h: &Helperrust-analyzer cargo handlebars 5.1.2 render/Helper#<'_>, |
| 1014 | _: &Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'_>, |
| 1015 | _: &Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 1016 | _: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'_, '_>, |
| 1017 | out: &mut dyn Outputrust-analyzer cargo handlebars 5.1.2 output/Output#| |
| 1018 | -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 1019 | out.writerust-analyzer cargo handlebars 5.1.2 output/Output#write().(&h.paramrust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]param().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().valuerust-analyzer cargo handlebars 5.1.2 json/value/impl#[`PathAndJson<'rc>`]value().().renderrust-analyzer cargo handlebars 5.1.2 json/value/impl#[Json][JsonRender]render().()) |
| 1020 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|_| ()) |
| 1021 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#::fromrust-analyzer cargo handlebars 5.1.2 error/impl#[RenderError][`From<IOError>`]from().) |
| 1022 | }, |
| 1023 | ), |
| 1024 | ); |
| 1025 | |
| 1026 | let mut sw = StringWriterrust-analyzer cargo handlebars 5.1.2 support/str/StringWriter#::newrust-analyzer cargo handlebars 5.1.2 support/str/impl#[StringWriter]new().(); |
| 1027 | let mut m: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 1028 | m.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().("a".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "123".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 1029 | |
| 1030 | { |
| 1031 | if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) = r.render_template_to_writerust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template_to_write().("{{format (format a)}}", &m, &mut sw) { |
| 1032 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("{}", e); |
| 1033 | } |
| 1034 | } |
| 1035 | |
| 1036 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(sw.into_stringrust-analyzer cargo handlebars 5.1.2 support/str/impl#[StringWriter]into_string().(), "123".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 1037 | } |
| 1038 | |
| 1039 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1040 | fn test_render_error_line_norust-analyzer cargo handlebars 5.1.2 render/test/test_render_error_line_no().() { |
| 1041 | let mut r = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 1042 | let m: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(); |
| 1043 | |
| 1044 | let name = "invalid_template"; |
| 1045 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r |
| 1046 | .register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().(name, "<h1>\n{{#if true}}\n {{#each}}{{/each}}\n{{/if}}") |
| 1047 | .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1048 | |
| 1049 | if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) = r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().(name, &m) { |
| 1050 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(e.line_norust-analyzer cargo handlebars 5.1.2 error/RenderError#line_no..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), 3); |
| 1051 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(e.column_norust-analyzer cargo handlebars 5.1.2 error/RenderError#column_no..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), 3); |
| 1052 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(e.template_namerust-analyzer cargo handlebars 5.1.2 error/RenderError#template_name., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(name.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())); |
| 1053 | } else { |
| 1054 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Error expected"); |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1059 | fn test_partial_failback_renderrust-analyzer cargo handlebars 5.1.2 render/test/test_partial_failback_render().() { |
| 1060 | let mut r = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 1061 | |
| 1062 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r |
| 1063 | .register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("parent", "<html>{{> layout}}</html>") |
| 1064 | .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1065 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r |
| 1066 | .register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().( |
| 1067 | "child", |
| 1068 | "{{#*inline \"layout\"}}content{{/inline}}{{#> parent}}{{> seg}}{{/parent}}", |
| 1069 | ) |
| 1070 | .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1071 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r.register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("seg", "1234").is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1072 | |
| 1073 | let r = r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("child", &true).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("should work"); |
| 1074 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r, "<html>content</html>"); |
| 1075 | } |
| 1076 | |
| 1077 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1078 | fn test_key_with_slashrust-analyzer cargo handlebars 5.1.2 render/test/test_key_with_slash().() { |
| 1079 | let mut r = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 1080 | |
| 1081 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r |
| 1082 | .register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("t", "{{#each this}}{{@key}}: {{this}}\n{{/each}}") |
| 1083 | .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1084 | |
| 1085 | let r = r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("t", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"/foo": "bar"})).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1086 | |
| 1087 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r, "/foo: bar\n"); |
| 1088 | } |
| 1089 | |
| 1090 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1091 | fn test_commentrust-analyzer cargo handlebars 5.1.2 render/test/test_comment().() { |
| 1092 | let r = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 1093 | |
| 1094 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1095 | r.render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().("Hello {{this}} {{! test me }}", &0) |
| 1096 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 1097 | "Hello 0 " |
| 1098 | ); |
| 1099 | } |
| 1100 | |
| 1101 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1102 | fn test_zero_args_helerrust-analyzer cargo handlebars 5.1.2 render/test/test_zero_args_heler().() { |
| 1103 | let mut r = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 1104 | |
| 1105 | r.register_helperrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_helper().( |
| 1106 | "name", |
| 1107 | 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().( |
| 1108 | |_: &Helperrust-analyzer cargo handlebars 5.1.2 render/Helper#<'_>, |
| 1109 | _: &Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'_>, |
| 1110 | _: &Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 1111 | _: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'_, '_>, |
| 1112 | out: &mut dyn Outputrust-analyzer cargo handlebars 5.1.2 output/Output#| |
| 1113 | -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 1114 | out.writerust-analyzer cargo handlebars 5.1.2 output/Output#write().("N/A").map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#::intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().) |
| 1115 | }, |
| 1116 | ), |
| 1117 | ); |
| 1118 | |
| 1119 | r.register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("t0", "Output name: {{name}}") |
| 1120 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1121 | r.register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("t1", "Output name: {{first_name}}") |
| 1122 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1123 | r.register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("t2", "Output name: {{./name}}") |
| 1124 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1125 | |
| 1126 | // when "name" is available in context, use context first |
| 1127 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1128 | r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("t0", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"name": "Alex"})).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 1129 | "Output name: N/A" |
| 1130 | ); |
| 1131 | |
| 1132 | // when "name" is unavailable, call helper with same name |
| 1133 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1134 | r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("t2", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"name": "Alex"})).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 1135 | "Output name: Alex" |
| 1136 | ); |
| 1137 | |
| 1138 | // output nothing when neither context nor helper available |
| 1139 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1140 | r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("t1", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"name": "Alex"})).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 1141 | "Output name: " |
| 1142 | ); |
| 1143 | |
| 1144 | // generate error in strict mode for above case |
| 1145 | r.set_strict_moderust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]set_strict_mode().(true); |
| 1146 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("t1", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"name": "Alex"})).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1147 | |
| 1148 | // output nothing when helperMissing was defined |
| 1149 | r.set_strict_moderust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]set_strict_mode().(false); |
| 1150 | r.register_helperrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_helper().( |
| 1151 | "helperMissing", |
| 1152 | 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().( |
| 1153 | |h: &Helperrust-analyzer cargo handlebars 5.1.2 render/Helper#<'_>, |
| 1154 | _: &Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#<'_>, |
| 1155 | _: &Contextrust-analyzer cargo handlebars 5.1.2 context/Context#, |
| 1156 | _: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#<'_, '_>, |
| 1157 | out: &mut dyn Outputrust-analyzer cargo handlebars 5.1.2 output/Output#| |
| 1158 | -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> { |
| 1159 | let name = h.namerust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]name().(); |
| 1160 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(out, "{} not resolved", name)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 1161 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 1162 | }, |
| 1163 | ), |
| 1164 | ); |
| 1165 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1166 | r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("t1", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"name": "Alex"})).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 1167 | "Output name: first_name not resolved" |
| 1168 | ); |
| 1169 | } |
| 1170 | |
| 1171 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1172 | fn test_identifiers_starting_with_numbersrust-analyzer cargo handlebars 5.1.2 render/test/test_identifiers_starting_with_numbers().() { |
| 1173 | let mut r = Registryrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().(); |
| 1174 | |
| 1175 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r |
| 1176 | .register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("r1", "{{#if 0a}}true{{/if}}") |
| 1177 | .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1178 | let r1 = r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("r1", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"0a": true})).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1179 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r1, "true"); |
| 1180 | |
| 1181 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r.register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("r2", "{{eq 1a 1}}").is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1182 | let r2 = r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("r2", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"1a": 2, "a": 1})).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1183 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r2, "false"); |
| 1184 | |
| 1185 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r |
| 1186 | .register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("r3", "0: {{0}} {{#if (eq 0 true)}}resolved from context{{/if}}\n1a: {{1a}} {{#if (eq 1a true)}}resolved from context{{/if}}\n2_2: {{2_2}} {{#if (eq 2_2 true)}}resolved from context{{/if}}") // YUP it is just eq that barfs! is if handled specially? maybe this test should go nearer to specific helpers that fail? |
| 1187 | .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1188 | let r3 = r |
| 1189 | .renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("r3", &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"0": true, "1a": true, "2_2": true})) |
| 1190 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1191 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1192 | r3, |
| 1193 | "0: true \n1a: true resolved from context\n2_2: true resolved from context" |
| 1194 | ); |
| 1195 | |
| 1196 | // these should all be errors: |
| 1197 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r.register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("r4", "{{eq 1}}").is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1198 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r.register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("r5", "{{eq a1}}").is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1199 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r.register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().("r6", "{{eq 1a}}").is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 1200 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("r4", &()).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1201 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("r5", &()).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1202 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("r6", &()).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 1203 | } |
| 1204 | } |