Changeset 41

Show
Ignore:
Timestamp:
05/20/2006 11:37:18 (3 years ago)
Author:
why
Message:
  • lib/markaby/builder.rb: return output helpers as fragments (thanks, murphy!)
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/xhtml-careful/lib/markaby/builder.rb

    r40 r41  
    146146        block = proc { text(str) } 
    147147      end 
    148       stream = @streams.first 
    149       f1 = stream.length 
    150       @builder.method_missing(tag, *args, &block) 
    151       f2 = stream.length - f1 
    152       Fragment.new(stream, f1, f2) 
     148      fragment { @builder.method_missing(tag, *args, &block) } 
    153149    end 
    154150 
     
    186182      elsif @helpers.respond_to?(sym) 
    187183        r = @helpers.send(sym, *args, &block) 
    188         @builder << r if @output_helpers 
    189         r 
     184        if @output_helpers 
     185            fragment { @builder << r } 
     186        else 
     187            r 
     188        end 
    190189      elsif instance_variable_get("@#{sym}") 
    191190        instance_variable_get("@#{sym}") 
     
    228227    end 
    229228 
     229    private 
     230 
     231    def fragment 
     232      stream = @streams.first 
     233      f1 = stream.length 
     234      yield 
     235      f2 = stream.length - f1 
     236      Fragment.new(stream, f1, f2) 
     237    end 
     238 
    230239  end 
    231240  class Fragment