Skip to content

Commit

Permalink
feat(filters): Implement a dummy compact
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed May 16, 2017
1 parent f6fcd6c commit 44d4d06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,16 @@ pub fn map(input: &Value, args: &[Value]) -> FilterResult {
Ok(Value::Array(result))
}

// TODO compact removes nulls from an iterable. For hashes, you can specify which property you
// want to filter out if it maps to Null.
// liquid-rust doesn't have the concept of Null. Are there some behavior gaps we have that should
// force us to support Null? Should we make this function a no-op?
/// Remove nulls from an iterable. For hashes, you can specify which property you
/// want to filter out if it maps to Null.
pub fn compact(input: &Value, args: &[Value]) -> FilterResult {
try!(check_args_len(args, 0, 1));

// No-op. liquid-rust doesn't have Null but this is left in for compatibility with existing
// shopofy/liquid code. Should it be a no-op, error, or not exist?

Ok(input.clone())
}

pub fn replace(input: &Value, args: &[Value]) -> FilterResult {
try!(check_args_len(args, 1, 1));
Expand Down
1 change: 1 addition & 0 deletions src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ impl Renderable for Template {
context.maybe_add_filter("append", Box::new(filters::append));
context.maybe_add_filter("capitalize", Box::new(filters::capitalize));
context.maybe_add_filter("ceil", Box::new(filters::ceil));
context.maybe_add_filter("compact", Box::new(filters::compact));
context.maybe_add_filter("concat", Box::new(filters::concat));
context.maybe_add_filter("date", Box::new(filters::date));
context.maybe_add_filter("default", Box::new(filters::default));
Expand Down

0 comments on commit 44d4d06

Please sign in to comment.