RailsCasts Pro episodes are now free!
Learn more or hide this
Resources
<%= liquidize @page.content, 'page' => @page %>
config.gem 'liquid'
def liquidize(content, arguments) RedCloth.new(Liquid::Template.parse(content).render(arguments, :filters => [LiquidFilters])).to_html end
module LiquidFilters include ActionView::Helpers::NumberHelper def currency(price) number_to_currency(price) end end
liquid_methods :name
liquid_methods :products def products Product.all end
liquid_methods :name, :price, :category
rake gems:install gem server
# page liquid content {% for product in page.products %} *{{ product.name }}* {{ product.price | currency }} Category: {{ product.category.name }} {% endfor %}
Full Source Code