I think I have the full extraction code.
This commit is contained in:
parent
ae74ce411a
commit
d2904913ad
@ -100,8 +100,8 @@ pub struct Container<'a> {
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct NamedBlock<'a> {
|
||||
name: &'a str,
|
||||
contents: Option<Body<'a>>,
|
||||
pub name: &'a str,
|
||||
pub contents: Option<Body<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
@ -10,10 +10,13 @@ struct InlinePartialTreeElement<'a> {
|
||||
}
|
||||
|
||||
impl<'a> InlinePartialTreeElement<'a> {
|
||||
pub fn new(parent: Option<&'a InlinePartialTreeElement<'a>>) -> InlinePartialTreeElement<'a> {
|
||||
pub fn new(
|
||||
parent: Option<&'a InlinePartialTreeElement<'a>>,
|
||||
blocks: HashMap<&'a str, &'a Option<Body<'a>>>,
|
||||
) -> InlinePartialTreeElement<'a> {
|
||||
InlinePartialTreeElement {
|
||||
parent: parent,
|
||||
blocks: HashMap::new(),
|
||||
blocks: blocks,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -49,6 +52,43 @@ fn extract_inline_partials_from_tag<'a, 'b>(
|
||||
) {
|
||||
match tag {
|
||||
DustTag::DTComment(..) => (),
|
||||
DustTag::DTSpecial(..) => (),
|
||||
DustTag::DTReference(..) => (),
|
||||
DustTag::DTSection(container) => {
|
||||
match &container.contents {
|
||||
None => (),
|
||||
Some(body) => extract_inline_partials_from_body(blocks, &body),
|
||||
};
|
||||
match &container.else_contents {
|
||||
None => (),
|
||||
Some(body) => extract_inline_partials_from_body(blocks, &body),
|
||||
};
|
||||
}
|
||||
DustTag::DTExists(container) => {
|
||||
match &container.contents {
|
||||
None => (),
|
||||
Some(body) => extract_inline_partials_from_body(blocks, &body),
|
||||
};
|
||||
match &container.else_contents {
|
||||
None => (),
|
||||
Some(body) => extract_inline_partials_from_body(blocks, &body),
|
||||
};
|
||||
}
|
||||
DustTag::DTNotExists(container) => {
|
||||
match &container.contents {
|
||||
None => (),
|
||||
Some(body) => extract_inline_partials_from_body(blocks, &body),
|
||||
};
|
||||
match &container.else_contents {
|
||||
None => (),
|
||||
Some(body) => extract_inline_partials_from_body(blocks, &body),
|
||||
};
|
||||
}
|
||||
DustTag::DTPartial(..) => (),
|
||||
DustTag::DTInlinePartial(named_block) => {
|
||||
blocks.insert(&named_block.name, &named_block.contents);
|
||||
}
|
||||
DustTag::DTBlock(..) => (),
|
||||
_ => (), // TODO: Implement the rest
|
||||
}
|
||||
}
|
||||
|
@ -183,6 +183,13 @@ impl<'a> DustRenderer<'a> {
|
||||
return Ok(rendered_content);
|
||||
}
|
||||
}
|
||||
DustTag::DTInlinePartial(named_block) => {
|
||||
// Inline partials are blank during rendering (they get injected into blocks)
|
||||
return Ok("".to_owned());
|
||||
}
|
||||
DustTag::DTBlock(named_block) => {
|
||||
// TODO: Implement
|
||||
}
|
||||
_ => (), // TODO: Implement the rest
|
||||
}
|
||||
Ok("".to_owned())
|
||||
|
Loading…
x
Reference in New Issue
Block a user