I'm using Liquid as my templating laguage for price tags that users can download from my site.
Liquid works fine alone, however no custom filters work. They simply doesn't do anything.
Here is an example:
$ {{item.primary_offer.subscription.month_price | no_decimal}},- per month
this should result in:
$ 199,- per month.
But the filter does not work so the result is:
$ 199.0,- per month.
My filters file looks like this:
module LiquidFilters
include ActionView::Helpers::NumberHelper
def no_decimal(input)
number_to_currency(input.to_f, precision: 0)
end
end
Liquid::Template.register_filter(LiquidFilters)
and my application helper that renders the liquid input looks like this:
def liquidize(content, arguments)
Liquid::Template.parse(content).render(arguments, :filters => [LiquidFilters])
end
I solved this problem by moving the LiquidFilters module into the applications helper file (under the ApplicationHelper module).
Everything the suddenly worked.
I do not understand why this made a difference but it did work. If anyone can explain this ill upvote their answer. :)