lib/linner.rb in linner-0.6.0 vs lib/linner.rb in linner-0.6.1
- old
+ new
@@ -1,6 +1,6 @@
-require "nokogiri"
+require "hpricot"
require "linner/version"
require "linner/command"
require "linner/asset"
require "linner/cache"
@@ -161,19 +161,19 @@
asset.compress if compile?
asset.write
end
def replace_attributes file
- doc = Nokogiri::HTML.parse(File.read file)
+ doc = Hpricot(File.read file)
replace_tag_with_manifest_value doc, "script", "src"
replace_tag_with_manifest_value doc, "link", "href"
File.open(file, "w") {|f| f.write doc.to_html}
end
def replace_tag_with_manifest_value doc, tag, attribute
- doc.search(tag).each do |x|
- next unless node = x.attributes[attribute]
- x.set_attribute attribute, manifest[node.value]
+ doc.search("//#{tag}").each do |tag|
+ value = tag.attributes[attribute]
+ tag.attributes[attribute] = manifest[value] if value and manifest[value]
end
end
def dump_manifest
File.open(File.join(env.public_folder, env.manifest), "w") do |f|