Implemented the renderer logic.
I should just need to implement ContextElement at this point.
This commit is contained in:
parent
b45448edbd
commit
2f515e068d
@ -115,7 +115,7 @@ pub struct ParameterizedBlock<'a> {
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Partial<'a> {
|
||||
pub name: String,
|
||||
params: Vec<KVPair<'a>>,
|
||||
pub params: Vec<KVPair<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
@ -25,4 +25,4 @@ impl<'a> ParametersContext<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ContextElement for ParametersContext<'a> {}
|
||||
// impl<'a> ContextElement for ParametersContext<'a> {}
|
||||
|
@ -174,8 +174,16 @@ impl<'a> DustRenderer<'a> {
|
||||
}
|
||||
}
|
||||
DustTag::DTPartial(partial) => {
|
||||
let rendered_content = self.render(&partial.name, breadcrumbs)?;
|
||||
return Ok(rendered_content);
|
||||
if partial.params.is_empty() {
|
||||
let rendered_content = self.render(&partial.name, breadcrumbs)?;
|
||||
return Ok(rendered_content);
|
||||
} else {
|
||||
let injected_context = ParametersContext::new(breadcrumbs, &partial.params);
|
||||
let mut new_breadcrumbs = breadcrumbs.clone();
|
||||
new_breadcrumbs.insert(new_breadcrumbs.len() - 1, &injected_context);
|
||||
let rendered_content = self.render(&partial.name, &new_breadcrumbs)?;
|
||||
return Ok(rendered_content);
|
||||
}
|
||||
}
|
||||
_ => (), // TODO: Implement the rest
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user