Changeset 221

Show
Ignore:
Timestamp:
04/27/07 17:41:14 (2 years ago)
Author:
v..@exdolo.com
Message:

- modified the behavior of image_tag so that the path parameter is a member of the options hash. previously to send options you had to call it like so: image_tag('foo.gif',,:class => 'bar'). now you'd call it like so: image_tag('foo.gif',:class => 'bar', :path => '/files/'), where path is the image path prefix (it and all options are still... optional)
- added a spec for the ViewContextMixin? (only image_tag is currently spec'd)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/merb/mixins/view_context_mixin.rb

    r187 r221  
    1818    end 
    1919     
    20     def image_tag(img, path='/images/', opts={}) 
    21       %{<img src="#{path+img}" #{opts.map{|k,v| "#{k}=\"#{v}\""}.join(' ')} />} 
     20    # creates an <img> tag 
     21    # defaults to a src path prefix of /images/ 
     22    # 
     23    # image_tag('foo.gif') => <img src='/images/foo.gif' /> 
     24    # image_tag('foo.gif', :class => 'bar') => <img src='/images/foo.gif' class='bar' /> 
     25    # 
     26    # you can override the default path by sending a :path parameter in the opts 
     27    # 
     28    # image_tag('foo.gif', :path => '/files/') => <img src='/files/foo.gif' /> 
     29    # 
     30    def image_tag(img, opts={}) 
     31      opts[:path] ||= '/images/' 
     32      %{<img src="#{opts.delete(:path) + img}" #{opts.map{|k,v| "#{k}=\"#{v}\""}.join(' ')} />} 
    2233    end 
    2334