lib/artwork/view.rb in artwork-0.2.0 vs lib/artwork/view.rb in artwork-0.2.1
- old
+ new
@@ -1,13 +1,10 @@
module Artwork
module View
def activate_resolution_independence
content_tag :script do
- Thread.current[:artwork_script] ||= begin
- artwork_script_path = Artwork.root_path + '/assets/javascripts/artwork.js'
- Uglifier.compile(File.read(artwork_script_path)).html_safe
- end
+ Thread.current[:artwork_script] ||= compile_artwork_script
end
end
def artwork_tag(record, attachment_name, size, options = {})
image_tag_options = options[:image] || {}
@@ -39,9 +36,20 @@
def extract_title_from(record)
if record.respond_to? :title
record.title
elsif record.respond_to? :name
record.name
+ end
+ end
+
+ def compile_artwork_script
+ artwork_script_path = Artwork.root_path + '/assets/javascripts/artwork.js'
+ compiled_script = Uglifier.compile(File.read(artwork_script_path))
+
+ if compiled_script.respond_to?(:html_safe)
+ compiled_script.html_safe
+ else
+ compiled_script
end
end
end
end