add global_filter

add a global filter using a proc
only add one proc and not an array
add tests to make sure the global_filter is applied after native filters
This commit is contained in:
Loren Hale
2015-07-12 16:46:43 +08:00
parent b42d35ff36
commit 0b11b573d9
5 changed files with 49 additions and 15 deletions
+14
View File
@@ -211,4 +211,18 @@ class TemplateTest < Minitest::Test
end
assert exception.is_a?(Liquid::ZeroDivisionError)
end
def test_global_filter_option_on_render
global_filter_proc = ->(output) { "#{output} filtered" }
rendered_template = Template.parse("{{name}}").render({ "name" => "bob" }, global_filter: global_filter_proc)
assert_equal 'bob filtered', rendered_template
end
def test_global_filter_option_when_native_filters_exist
global_filter_proc = ->(output) { "#{output} filtered" }
rendered_template = Template.parse("{{name | upcase}}").render({ "name" => "bob" }, global_filter: global_filter_proc)
assert_equal 'BOB filtered', rendered_template
end
end