Sha256: f0bb673962354cb7400ad384e447c888e542a54f18fef59b9f76d5b95fa85a37

Contents?: true

Size: 1.87 KB

Versions: 14

Compression:

Stored size: 1.87 KB

Contents

module Wisepdf
  module Helper
    module Legacy
      def wisepdf_stylesheet_tag(*sources)
        stylesheets_dir = ::Rails.root.join('public','stylesheets')
                
        sources.collect { |source|
          filename = ( source =~ /.css\z/ ? source : source + '.css' )  
          "<style type='text/css'>
            #{File.read(stylesheets_dir.join(filename))}
          </style>"
        }.join("\n").html_safe
      end

      def wisepdf_image_tag(img, options={})
        image_tag "file:///#{::Rails.root.join('public', 'images', img).pathname.to_s}", options
      end
      
      def wisepdf_javascript_tag(*sources)
        javascripts_dir = ::Rails.root.join('public','javascripts')
        
        sources.collect { |source|
          filename = ( source =~ /.js\z/ ? source : source + '.js' )
          "<script type='text/javascript'>
            //<![CDATA[
              #{File.read(javascripts_dir.join(filename))}
            //]]>
          </script>"
        }.join("\n").html_safe
      end
    end  
    
    module Assets
      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

      def wisepdf_image_tag(img, options={})
        image_tag "file:///#{::Rails.application.assets.find_asset(img).pathname.to_s}", options
      end
      
      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
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
wisepdf-1.2.5 lib/wisepdf/helper.rb
wisepdf-1.2.4 lib/wisepdf/helper.rb
wisepdf-1.2.3 lib/wisepdf/helper.rb
wisepdf-1.2.2 lib/wisepdf/helper.rb
wisepdf-1.2.1 lib/wisepdf/helper.rb
wisepdf-1.2.0 lib/wisepdf/helper.rb
wisepdf-1.1.3 lib/wisepdf/helper.rb
wisepdf-1.1.2 lib/wisepdf/helper.rb
wisepdf-1.1.1 lib/wisepdf/helper.rb
wisepdf-1.1.0 lib/wisepdf/helper.rb
wisepdf-1.0.3 lib/wisepdf/helper.rb
wisepdf-1.0.2 lib/wisepdf/helper.rb
wisepdf-1.0.1 lib/wisepdf/helper.rb
wisepdf-1.0.0 lib/wisepdf/helper.rb