summaryrefslogtreecommitdiffstats
path: root/vendor/handlebars/src/context.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:06:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:06:31 +0000
commit2ff14448863ac1a1dd9533461708e29aae170c2d (patch)
tree85b9fea2bbfe3f06473cfa381eed11f273b57c5c /vendor/handlebars/src/context.rs
parentAdding debian version 1.64.0+dfsg1-1. (diff)
downloadrustc-2ff14448863ac1a1dd9533461708e29aae170c2d.tar.xz
rustc-2ff14448863ac1a1dd9533461708e29aae170c2d.zip
Adding debian version 1.65.0+dfsg1-2.debian/1.65.0+dfsg1-2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--vendor/handlebars/src/context.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/vendor/handlebars/src/context.rs b/vendor/handlebars/src/context.rs
index 10e15fd90..86f99ba4d 100644
--- a/vendor/handlebars/src/context.rs
+++ b/vendor/handlebars/src/context.rs
@@ -45,7 +45,7 @@ fn parse_json_visitor<'a, 'reg>(
for path_seg in relative_path {
match path_seg {
PathSeg::Named(the_path) => {
- if let Some((holder, base_path)) = get_in_block_params(&block_contexts, the_path) {
+ if let Some((holder, base_path)) = get_in_block_params(block_contexts, the_path) {
with_block_param = Some((holder, base_path));
}
break;
@@ -171,10 +171,7 @@ impl Context {
block_contexts: &VecDeque<BlockContext<'reg>>,
) -> Result<ScopedJson<'reg, 'rc>, RenderError> {
// always use absolute at the moment until we get base_value lifetime issue fixed
- let resolved_visitor = parse_json_visitor(&relative_path, block_contexts, true);
-
- // debug logging
- debug!("Accessing context value: {:?}", resolved_visitor);
+ let resolved_visitor = parse_json_visitor(relative_path, block_contexts, true);
match resolved_visitor {
ResolvedPath::AbsolutePath(paths) => {
@@ -223,6 +220,12 @@ impl Context {
}
}
+impl From<Json> for Context {
+ fn from(data: Json) -> Context {
+ Context { data }
+ }
+}
+
#[cfg(test)]
mod test {
use crate::block::{BlockContext, BlockParams};
@@ -359,9 +362,9 @@ mod test {
#[test]
fn test_key_name_with_this() {
- let m = btreemap! {
- "this_name".to_string() => "the_value".to_string()
- };
+ let m = json!({
+ "this_name": "the_value"
+ });
let ctx = Context::wraps(&m).unwrap();
assert_eq!(
navigate_from_root(&ctx, "this_name").unwrap().render(),