diff --git a/src/parser.rs b/src/parser.rs index a6fcd8f70..c251d476a 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -10,7 +10,7 @@ use compiler; use interpreter; use super::Template; -#[derive(Default)] +#[derive(Default, Clone)] pub struct ParserBuilder { blocks: HashMap, tags: HashMap, @@ -113,11 +113,13 @@ impl ParserBuilder { filters::url_encode as interpreter::FnFilterValue) } + /// Register non-standard filters #[cfg(not(feature = "extra-filters"))] pub fn extra_filters(self) -> Self { self } + /// Register non-standard filters #[cfg(feature = "extra-filters")] pub fn extra_filters(self) -> Self { self.filter("pluralize", @@ -150,6 +152,7 @@ impl ParserBuilder { self } + /// Create a parser pub fn build(self) -> Parser { let Self { blocks, @@ -169,7 +172,7 @@ impl ParserBuilder { } } -#[derive(Default)] +#[derive(Default, Clone)] pub struct Parser { options: compiler::LiquidOptions, filters: HashMap, diff --git a/src/template.rs b/src/template.rs index 5082562f4..0a0446600 100644 --- a/src/template.rs +++ b/src/template.rs @@ -12,6 +12,7 @@ pub struct Template { } impl Template { + /// Renders an instance of the Template, using the given globals. pub fn render(&self, globals: &Object) -> Result { let mut data = interpreter::Context::new() .with_filters(self.filters.clone())