Skip to content

Commit

Permalink
feat(api): Add missing traits
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Dec 18, 2017
1 parent 111d10a commit e0f8270
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use compiler;
use interpreter;
use super::Template;

#[derive(Default)]
#[derive(Default, Clone)]
pub struct ParserBuilder {
blocks: HashMap<String, compiler::BoxedBlockParser>,
tags: HashMap<String, compiler::BoxedTagParser>,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -150,6 +152,7 @@ impl ParserBuilder {
self
}

/// Create a parser
pub fn build(self) -> Parser {
let Self {
blocks,
Expand All @@ -169,7 +172,7 @@ impl ParserBuilder {
}
}

#[derive(Default)]
#[derive(Default, Clone)]
pub struct Parser {
options: compiler::LiquidOptions,
filters: HashMap<String, interpreter::BoxedValueFilter>,
Expand Down
1 change: 1 addition & 0 deletions src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
let mut data = interpreter::Context::new()
.with_filters(self.filters.clone())
Expand Down

0 comments on commit e0f8270

Please sign in to comment.