Integrated new_breadcrumbs into exists and not exists, and partially integrated it into partials.
This commit is contained in:
parent
32c047a9b9
commit
17121aa85b
@ -250,29 +250,58 @@ impl<'a> DustRenderer<'a> {
|
||||
}
|
||||
}
|
||||
DustTag::DTExists(container) => {
|
||||
let new_breadcrumbs =
|
||||
Self::new_breadcrumbs(breadcrumbs, None, &container.explicit_context, None);
|
||||
let val = walk_path(breadcrumbs, &container.path.keys);
|
||||
return if val.map(|v| v.is_truthy()).unwrap_or(false) {
|
||||
self.render_maybe_body(&container.contents, breadcrumbs, blocks)
|
||||
self.render_maybe_body(
|
||||
&container.contents,
|
||||
new_breadcrumbs.as_ref().unwrap_or(breadcrumbs),
|
||||
blocks,
|
||||
)
|
||||
} else {
|
||||
self.render_maybe_body(&container.else_contents, breadcrumbs, blocks)
|
||||
self.render_maybe_body(
|
||||
&container.else_contents,
|
||||
new_breadcrumbs.as_ref().unwrap_or(breadcrumbs),
|
||||
blocks,
|
||||
)
|
||||
};
|
||||
}
|
||||
DustTag::DTNotExists(container) => {
|
||||
let new_breadcrumbs =
|
||||
Self::new_breadcrumbs(breadcrumbs, None, &container.explicit_context, None);
|
||||
let val = walk_path(breadcrumbs, &container.path.keys);
|
||||
return if !val.map(|v| v.is_truthy()).unwrap_or(false) {
|
||||
self.render_maybe_body(&container.contents, breadcrumbs, blocks)
|
||||
self.render_maybe_body(
|
||||
&container.contents,
|
||||
new_breadcrumbs.as_ref().unwrap_or(breadcrumbs),
|
||||
blocks,
|
||||
)
|
||||
} else {
|
||||
self.render_maybe_body(&container.else_contents, breadcrumbs, blocks)
|
||||
self.render_maybe_body(
|
||||
&container.else_contents,
|
||||
new_breadcrumbs.as_ref().unwrap_or(breadcrumbs),
|
||||
blocks,
|
||||
)
|
||||
};
|
||||
}
|
||||
DustTag::DTPartial(partial) => {
|
||||
let partial_name = self.render_partial_name(&partial.name, breadcrumbs, blocks)?;
|
||||
if partial.params.is_empty() {
|
||||
let rendered_content =
|
||||
self.render_template(&partial_name, breadcrumbs, Some(blocks))?;
|
||||
let new_breadcrumbs =
|
||||
Self::new_breadcrumbs(breadcrumbs, None, &partial.explicit_context, None);
|
||||
let rendered_content = self.render_template(
|
||||
&partial_name,
|
||||
new_breadcrumbs.as_ref().unwrap_or(breadcrumbs),
|
||||
Some(blocks),
|
||||
)?;
|
||||
return Ok(rendered_content);
|
||||
} else {
|
||||
let injected_context = ParametersContext::new(breadcrumbs, &partial.params);
|
||||
// TODO: need to add a special case where the
|
||||
// injected context is added 1 behind the existing
|
||||
// breadcrumbs when new_context_element does not
|
||||
// exist.
|
||||
let mut new_breadcrumbs = breadcrumbs.clone();
|
||||
new_breadcrumbs.insert(new_breadcrumbs.len() - 1, &injected_context);
|
||||
let rendered_content =
|
||||
|
Loading…
Reference in New Issue
Block a user