| 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(' ')} />} |
|---|