Module: Wisepdf::Helper::Assets

Defined in:
lib/wisepdf/helper.rb

Instance Method Summary collapse

Instance Method Details

#wisepdf_image_tag(img, options = {}) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/wisepdf/helper.rb', line 43

def wisepdf_image_tag(img, options={})
  if File.exists? img
    image_tag "file://#{img}", options
  elsif asset = ::Rails.application.assets.find_asset(img)
    image_tag "file:///#{asset.pathname.to_s}", options
  end
end

#wisepdf_javascript_tag(*sources) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/wisepdf/helper.rb', line 51

def wisepdf_javascript_tag(*sources)
  sources.collect { |source|
    filename = ( source =~ /.js\z/ ? source : source + '.js' )
    "<script type='text/javascript'>
      //<![CDATA[
        #{::Rails.application.assets.find_asset(filename)}
      //]]>
    </script>"
  }.join("\n").html_safe
end

#wisepdf_stylesheet_tag(*sources) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/wisepdf/helper.rb', line 34

def wisepdf_stylesheet_tag(*sources)
  sources.collect { |source|
    filename = ( source =~ /.css\z/ ? source : source + '.css' )
    "<style type='text/css'>
      #{::Rails.application.assets.find_asset(filename)}
    </style>"
  }.join("\n").html_safe
end