Module: WickedPdfHelper

Defined in:
lib/wicked_pdf_helper.rb

Defined Under Namespace

Modules: Assets

Instance Method Summary collapse

Instance Method Details

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



23
24
25
# File 'lib/wicked_pdf_helper.rb', line 23

def wicked_pdf_image_tag(img, options={})
  image_tag "file:///#{root_obj.join('public', 'images', img)}", options
end

#wicked_pdf_javascript_include_tag(*sources) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/wicked_pdf_helper.rb', line 31

def wicked_pdf_javascript_include_tag(*sources)
  begin
    sources.collect{ |source| wicked_pdf_javascript_src_tag(source, {}) }.join("\n").html_safe
  rescue NoMethodError
    sources.collect{ |source| wicked_pdf_javascript_src_tag(source, {}) }.join("\n")
  end
end

#wicked_pdf_javascript_src_tag(jsfile, options = {}) ⇒ Object



27
28
29
# File 'lib/wicked_pdf_helper.rb', line 27

def wicked_pdf_javascript_src_tag(jsfile, options={})
  javascript_src_tag "file:///#{root_obj.join('public','javascripts',jsfile)}", options
end


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/wicked_pdf_helper.rb', line 2

def wicked_pdf_stylesheet_link_tag(*sources)
  
  if Rails.root.kind_of?(Pathname)
    root_pathname = Rails.root
  elsif Rails.root.kind_of?(String)
    root_obj = Pathname(Rails.root)
  end

  css_dir = root_obj.join('public','stylesheets')
  
  begin
    sources.collect { |source|
      "<style type='text/css'>#{File.read(css_dir.join(source+'.css'))}</style>"
    }.join("\n").html_safe
  rescue NoMethodError
    sources.collect { |source|
      "<style type='text/css'>#{File.read(css_dir.join(source+'.css'))}</style>"
    }.join("\n")
  end
end