Class: AssetLinker
- Inherits:
-
DOMCompiler
- Object
- DOMCompiler
- AssetLinker
- Defined in:
- lib/compilers/assetLinker.rb
Constant Summary
Constants included from SqweezeUtils
SqweezeUtils::EMBED_MIME_TYPES
Instance Attribute Summary
Attributes inherited from DOMCompiler
Instance Method Summary collapse
Methods inherited from DOMCompiler
#css_cdata, #get_resource, #initialize, #iterate_over, #js_cdata
Methods included from SqweezeUtils
#ansi_bold, #ansi_green, #ansi_nocolour, #ansi_red, #ansi_yellow, #byteweight, #compression_percentage, #encoded_contents, #find_file_in_targetdir, #mime_type, #notify, #remap_filepath, #write_file
Constructor Details
This class inherits a constructor from DOMCompiler
Instance Method Details
#compile ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/compilers/assetLinker.rb', line 3 def compile iterate_over("link[@rel='stylesheet'], script[@src]") do |elm,doc| # Skip if the script has an absolute link next if elm.get_attribute('src') =~ /^http:\/\// # Otherwise delete. elm.parent.children.delete(elm) end dom_documents.each do |path| # Append concatenated JavaScript file. doc = Hpricot(open(path)) doc.search(@cm.get_conf(:append_scripts_to).to_s.downcase).append( "<script type='text/javascript' src='javascripts.min.js'></script>") stylesheets_html=<<EOF <!--[if lte IE 8]> <link href="stylesheets.min.mhtml.css" rel="stylesheet" /> <![endif]--> <!--[if IE 8]> <link href="stylesheets.min.datauri.css" rel="stylesheet" /> <![endif]--> <!--[if !IE]> <link href="stylesheets.min.datauri.css" rel="stylesheet" /> <![endif]--> EOF # Append ie conditional tags doc.search('head').append(stylesheets_html) write_file(doc.innerHTML,path) end end |