Module: HolderRails::Helpers

Defined in:
lib/holder_rails/helpers.rb

Instance Method Summary collapse

Instance Method Details

#holder_tag(size, text = '', theme = nil, html_options = {}, holder_options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/holder_rails/helpers.rb', line 3

def holder_tag(size, text='', theme=nil, html_options={}, holder_options={})
  size = "#{size}x#{size}" unless size =~ /\A\d+p?x\d+\z/

  holder_options[:text] = text unless text.to_s.empty?
  holder_options[:theme] = theme unless theme.nil?
  holder_options = holder_options.map {|e| e.join('=') }.join('&')

  options = { src: '', data: { src: "holder.js/#{size}?#{holder_options}" }}
  options = options.merge(html_options)

  tag :img, options
end