Changeset 76

Show
Ignore:
Timestamp:
08/23/2006 12:17:11 (2 years ago)
Author:
tec
Message:

lib/markaby: keep content_for Rails-only

Location:
trunk/lib/markaby
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/markaby/builder.rb

    r75 r76  
    127127      builder.target = @streams.last 
    128128      str 
    129     end 
    130  
    131     # Content_for will store the given block in an instance variable for later use  
    132     # in another template or in the layout. 
    133     # 
    134     # The name of the instance variable is content_for_<name> to stay consistent  
    135     # with @content_for_layout which is used by ActionView's layouts. 
    136     # 
    137     # Example: 
    138     # 
    139     #   content_for("header") do 
    140     #     h1 "Half Shark and Half Lion" 
    141     #   end 
    142     # 
    143     # If used several times, the variable will contain all the parts concatenated. 
    144     def content_for(name, &block) 
    145       @helpers.assigns["content_for_#{name}"] = 
    146         eval("@content_for_#{name} = (@content_for_#{name} || '') + capture(&block)") 
    147129    end 
    148130 
  • trunk/lib/markaby/rails.rb

    r62 r76  
    3939    # If used several times, the variable will contain all the parts concatenated. 
    4040    def content_for(name, &block) 
    41       eval "@content_for_#{name} = (@content_for_#{name} || '') + capture(&block)" 
     41      @helpers.assigns["content_for_#{name}"] = 
     42        eval("@content_for_#{name} = (@content_for_#{name} || '') + capture(&block)") 
    4243    end 
    4344  end