You have to place the filter in the lib
directory instead. The one in the application root, not the app/lib
one (if you have one).
How do I globally register a Liquid filter
-
02-10-2022 - |
سؤال
I created a custom Liquid filter
module LinkFilter
include ActionView::Helpers::UrlHelper
include Rails.application.routes.url_helpers
def link(input,source)
link_to input,source
end
end
and placed it in app/filters/LinkFilter.rb
How do I globally register the filter? According the Liquid documentation, adding this line at the end of the above file would register it globally:
Liquid::Template.register_filter(LinkFilter)
But it doesn't seem to work. Am I placing the filter in the wrong location or what?
المحلول
لا تنتمي إلى StackOverflow