Fluid plug

I am using a liquid plugin in my application. When using rails helper methods like form_for, check_box_tag, I get a form_for not defined error ..

Does anyone know how to use rails helper methods through a fluid plugin?

+3
source share
4 answers

I just communicated with this not so long ago - if you want to better understand what it takes to extend regular filters (including helper methods that you might need), I found this Railscast very useful: http://railscasts.com/episodes/118 -liquid

, , , (), . , . lib LiquidFilters, , :

# lib/liquid_filters.rb
module LiquidFilters
  include ActionView::Helpers::NumberHelper

  def currency(price)
    number_to_currency(price)
  end
end

, , , , : filters = > [LiquidFilters] ( , ), . , - , .

+5

- , rails ?

Liquid , . . https://github.com/Shopify/liquid/wiki/Liquid-for-Designers.

, , (. https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers).

Rails, Liquid .

Liquid.

{{ 'This is a long section of text' | truncate: 3 }}

{{ truncate('This is a long section of text', 3) }}
+1

html-, , link_to ( !), html- :

<a href="{link}">{{link_name}}</a>" 
+1

Source: https://habr.com/ru/post/1710837/


All Articles