문제

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