module Wisepdf::Helper::Assets

Public Instance Methods

wisepdf_image_tag(img, options={}) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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