Module: GTK::ViewsHelper
- Defined in:
- lib/gtk_webkit_pdf/gtk_views_helper_pdf.rb
Class Method Summary collapse
Instance Method Summary collapse
- #gtk_webkit_pdf_image_tag(img, options = {}) ⇒ Object
- #gtk_webkit_pdf_javascript_include_tag(*sources) ⇒ Object
- #gtk_webkit_pdf_javascript_src_tag(jsfile, options = {}) ⇒ Object
- #gtk_webkit_pdf_stylesheet_link_tag(*sources) ⇒ Object
Class Method Details
.root_path ⇒ Object
3 4 5 |
# File 'lib/gtk_webkit_pdf/gtk_views_helper_pdf.rb', line 3 def self.root_path String === Rails.root ? Pathname.new(Rails.root) : Rails.root end |
Instance Method Details
#gtk_webkit_pdf_image_tag(img, options = {}) ⇒ Object
13 14 15 |
# File 'lib/gtk_webkit_pdf/gtk_views_helper_pdf.rb', line 13 def gtk_webkit_pdf_image_tag(img, = {}) image_tag("file:///#{ViewsHelper.root_path.join('app', 'assets', 'images', img)}", ) end |
#gtk_webkit_pdf_javascript_include_tag(*sources) ⇒ Object
21 22 23 24 |
# File 'lib/gtk_webkit_pdf/gtk_views_helper_pdf.rb', line 21 def gtk_webkit_pdf_javascript_include_tag(*sources) js_text = sources.collect { |source| gtk_webkit_pdf_javascript_src_tag(source, {}) }.join('\n') js_text.respond_to?(:html_safe) ? js_text.html_safe : js_text end |
#gtk_webkit_pdf_javascript_src_tag(jsfile, options = {}) ⇒ Object
17 18 19 |
# File 'lib/gtk_webkit_pdf/gtk_views_helper_pdf.rb', line 17 def gtk_webkit_pdf_javascript_src_tag(jsfile, = {}) javascript_src_tag("file:///#{ViewsHelper.root_path.join('app', 'assets', 'javascripts', jsfile)}", ) end |
#gtk_webkit_pdf_stylesheet_link_tag(*sources) ⇒ Object
7 8 9 10 11 |
# File 'lib/gtk_webkit_pdf/gtk_views_helper_pdf.rb', line 7 def gtk_webkit_pdf_stylesheet_link_tag(*sources) css_dir = ViewsHelper.root_path.join('app', 'assets', 'stylesheets') css_text = sources.collect { |source| "<style type='text/css'>#{File.read(css_dir.join(sources+'.css'))}</style>" }.join('\n') css_text.respond_to?(:html_safe) ? css_text.html_safe : css_text end |