From 250d4284646d98b58dca39bf9a093c1e9bedca48 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 6 Jun 2020 23:17:50 -0400 Subject: [PATCH] Updated Partial for the new architecture. --- src/renderer/renderer.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/renderer/renderer.rs b/src/renderer/renderer.rs index 0973708..cf24470 100644 --- a/src/renderer/renderer.rs +++ b/src/renderer/renderer.rs @@ -306,6 +306,38 @@ impl<'a> DustRenderer<'a> { ), }; } + DustTag::DTPartial(partial) => { + let partial_name = self.render_partial_name(&partial.name, breadcrumbs)?; + if partial.params.is_empty() { + let new_breadcrumbs = self.new_breadcrumbs_partial( + breadcrumbs, + breadcrumbs, + None, + &partial.explicit_context, + ); + let rendered_content = self.render_template( + &partial_name, + new_breadcrumbs.as_ref().unwrap_or(breadcrumbs), + Some(blocks.blocks), + )?; + return Ok(rendered_content); + } else { + let injected_context = + ParametersContext::new(self, breadcrumbs, &partial.params); + let new_breadcrumbs = self.new_breadcrumbs_partial( + breadcrumbs, + breadcrumbs, + Some(&injected_context), + &partial.explicit_context, + ); + let rendered_content = self.render_template( + &partial_name, + new_breadcrumbs.as_ref().unwrap_or(breadcrumbs), + Some(blocks.blocks), + )?; + return Ok(rendered_content); + } + } _ => panic!("Unsupported tag"), } Ok("".to_owned())