diff --git a/Getting-Liquid-to-Work-in-Rails.textile b/Getting-Liquid-to-Work-in-Rails.textile index c75e436..7c39a2d 100644 --- a/Getting-Liquid-to-Work-in-Rails.textile +++ b/Getting-Liquid-to-Work-in-Rails.textile @@ -10,15 +10,16 @@ h3. Helpers become filters A note about helpers. Liquid's Rails plugin tries to use your helpers as Filters. -Your helpers will always receive the piped-in text as the first parameter, and then any Filter parameters (passed after the colon). +Your helpers will always receive the piped-in text as the first parameter, +and then any Filter parameters (passed after the colon). Helper:
- module ApplicationHelper - def truncate(input, length) - input[0..length] + '...' - end - end +module ApplicationHelper + def truncate(input, length) + input[0..length] + '...' + end +endLiquid: @@ -30,8 +31,10 @@ Liquid: h2. Using Rails model data and methods in Liquid templates When you pass variables to be available in a Liquid template, -Liquid accepts a limited number of object types -- Strings, Arrays, Hashes, Numerics, and Booleans. -If you'd like to pass your ActiveRecord (or other) objects to a Liquid template, you have three basic approaches: +Liquid accepts a limited number of object types -- +Strings, Arrays, Hashes, Numerics, and Booleans. +If you'd like to pass your ActiveRecord (or other) objects to a Liquid template, +you have three basic approaches: The easy way is to add a @liquid_methods@ call: @@ -42,10 +45,14 @@ class Post < ActiveRecord::Base "Behind the scenes":http://github.com/tobi/liquid/tree/master/lib/liquid/module_ex.rb, -@liquid_methods@ actually constructs a "Liquid Drop":http://liquid.rubyforge.org/classes/Liquid/Drop.html with the methods you include. This way, you have lazy loading (say, of associated models such as "comments" in the example above) of methods. +@liquid_methods@ actually constructs a +"Liquid Drop":http://liquid.rubyforge.org/classes/Liquid/Drop.html with the methods you include. +This way, you have lazy loading +(say, of associated models such as "comments" in the example above) of methods. An alternate route is to add a @to_liquid@ call in your object, -returning either one of the types listed above (string, array, hash, etc) or an object that in turn responds to @to_liquid@. +returning either one of the types listed above (string, array, hash, etc) +or an object that in turn responds to @to_liquid@.
class Post < ActiveRecord::Base @@ -55,5 +62,7 @@ class Post < ActiveRecord::Base end-Finally, you can write and register a completely new "Liquid Drop":http://liquid.rubyforge.org/classes/Liquid/Drop.html class. -This enables you to pull from various models and helps you consolidate (lazy-loaded) methods used just for passing data to templates. \ No newline at end of file +Finally, you can write and register a completely new +"Liquid Drop":http://liquid.rubyforge.org/classes/Liquid/Drop.html class. +This enables you to pull from various models +and helps you consolidate (lazy-loaded) methods used just for passing data to templates. \ No newline at end of file