Added a test for backtracking.

DustJS appears to not do any backtracking.
This commit is contained in:
Tom Alexander
2020-05-03 16:49:34 -04:00
parent 2b6c3990a9
commit c3fe7b47af
4 changed files with 44 additions and 4 deletions

View File

@@ -178,7 +178,7 @@ impl<'a> DustRenderer<'a> {
}
}
fn walk_path<'a>(
fn new_walk_path<'a>(
context: &'a dyn ContextElement,
path: &Vec<&str>,
breadcrumbs: Vec<&'a dyn ContextElement>,
@@ -192,6 +192,21 @@ fn walk_path<'a>(
Ok(output)
}
// TODO: rename walk_path_from_single_level
/// Attempts to walk a path from only 1 level in the context breadcrumbs
fn walk_path<'a>(
context: &'a dyn ContextElement,
path: &Vec<&str>,
) -> Result<&'a dyn ContextElement, RenderError<'a>> {
let mut output = context;
for elem in path.iter() {
output = output.walk(elem)?;
}
Ok(output)
}
#[cfg(test)]
mod tests {
use super::*;