Getting the left and right sides.

This commit is contained in:
Tom Alexander
2020-05-10 14:22:59 -04:00
parent 012028b0bc
commit 7a8247f38a
4 changed files with 38 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
use crate::parser::template;
use crate::parser::Body;
use crate::parser::DustTag;
use crate::parser::KVPair;
use crate::parser::RValue;
use crate::parser::Special;
use crate::parser::Template;
use crate::parser::TemplateElement;
@@ -222,6 +224,28 @@ impl<'a> DustRenderer<'a> {
},
};
}
DustTag::DTHelperEquals(parameterized_block) => {
let param_map: HashMap<&'a str, &'a RValue<'a>> = parameterized_block
.params
.iter()
.map(|pair: &KVPair<'a>| (pair.key, &pair.value))
.collect();
let left_side: Result<&dyn ContextElement, WalkError> = match param_map.get("key") {
None => return Ok("".to_owned()),
Some(rval) => match rval {
RValue::RVString(text) => Ok(text),
RValue::RVPath(path) => walk_path(breadcrumbs, &path.keys),
},
};
let right_side: Result<&dyn ContextElement, WalkError> =
match param_map.get("value") {
None => Err(WalkError::CantWalk),
Some(rval) => match rval {
RValue::RVString(text) => Ok(text),
RValue::RVPath(path) => walk_path(breadcrumbs, &path.keys),
},
};
}
_ => (), // TODO: Implement the rest
}
Ok("".to_owned())