lib/jammit/packager.rb in jammit-0.3.3 vs lib/jammit/packager.rb in jammit-0.4.0
- old
+ new
@@ -40,11 +40,11 @@
output_dir ||= File.join(PUBLIC_ROOT, Jammit.package_path)
cacheable(:js, output_dir).each {|p| cache(p, 'js', pack_javascripts(p), output_dir) }
cacheable(:jst, output_dir).each {|p| cache(p, 'jst', pack_templates(p), output_dir) }
cacheable(:css, output_dir).each do |p|
cache(p, 'css', pack_stylesheets(p), output_dir)
- if Jammit.embed_images
+ if Jammit.embed_assets
cache(p, 'css', pack_stylesheets(p, :datauri), output_dir, :datauri)
if Jammit.mhtml_enabled && base_url
mtime = Time.now
asset_url = "#{base_url}#{Jammit.asset_url(p, :css, :mhtml, mtime)}"
cache(p, 'css', pack_stylesheets(p, :mhtml, asset_url), output_dir, :mhtml, mtime)
@@ -91,10 +91,11 @@
# Look up a package asset list by name, raising an exception if the
# package has gone missing.
def package_for(package, extension)
pack = @packages[extension] && @packages[extension][package]
+ pack ||= @packages[:js] && @packages[:js][package] if extension == :jst
pack || not_found(package, extension)
end
# Absolute globs are absolute -- relative globs are relative to ASSET_ROOT.
def glob_files(glob)
@@ -124,10 +125,15 @@
config.each do |name, globs|
globs ||= []
packages[name] = {}
paths = globs.map {|glob| glob_files(glob) }.flatten.uniq
packages[name][:paths] = paths
- packages[name][:urls] = paths.map {|path| path.sub(PATH_TO_URL, '') }
+ if !paths.grep(JS_EXT).empty? && !paths.grep(JST_EXT).empty?
+ packages[name][:urls] = paths.grep(JS_EXT).map {|path| path.sub(PATH_TO_URL, '') }
+ packages[name][:urls] += [Jammit.asset_url(name, :jst)]
+ else
+ packages[name][:urls] = paths.map {|path| path.sub(PATH_TO_URL, '') }
+ end
end
packages
end
# Raise a PackageNotFound exception for missing packages...
\ No newline at end of file