質問

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?

役に立ちましたか?

解決

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).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top