Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain position of JST templates #80

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/jammit/compressor.rb
Expand Up @@ -64,10 +64,14 @@ def initialize
# Concatenate together a list of JavaScript paths, and pass them through the
# YUI Compressor (with munging enabled). JST can optionally be included.
def compress_js(paths)
if (jst_paths = paths.grep(Jammit.template_extension_matcher)).empty?
jst_paths = paths.grep(Jammit.template_extension_matcher)
if jst_paths.empty?
js = concatenate(paths)
else
js = concatenate(paths - jst_paths) + compile_jst(jst_paths)
fjst_idx = paths.index(jst_paths.first)
js_paths_a = (paths - jst_paths.drop(1)).shift(fjst_idx)
js_paths_b = (paths - jst_paths.drop(1)).drop(fjst_idx+1)
js = concatenate(js_paths_a) + compile_jst(jst_paths) + concatenate(js_paths_b)
end
Jammit.compress_assets ? @js_compressor.compress(js) : js
end
Expand Down
11 changes: 5 additions & 6 deletions lib/jammit/packager.rb
Expand Up @@ -142,12 +142,11 @@ def create_packages(config)
packages[name] = {}
paths = globs.flatten.uniq.map {|glob| glob_files(glob) }.flatten.uniq
packages[name][:paths] = paths
if !paths.grep(Jammit.template_extension_matcher).empty?
packages[name][:urls] = paths.grep(JS_EXTENSION).map {|path| path.sub(PATH_TO_URL, '') }
packages[name][:urls] += [Jammit.asset_url(name, Jammit.template_extension)]
else
packages[name][:urls] = paths.map {|path| path.sub(PATH_TO_URL, '') }
end
jst_paths = paths.grep(Jammit.template_extension_matcher)
fjst_idx = paths.index(jst_paths.shift)

packages[name][:urls] = (paths - jst_paths).map {|path| path.sub(PATH_TO_URL, '') }
packages[name][:urls][fjst_idx] = Jammit.asset_url(name, Jammit.template_extension) if fjst_idx
end
packages
end
Expand Down