lib/roda/plugins/assets.rb in roda-cj-1.0.3 vs lib/roda/plugins/assets.rb in roda-cj-1.0.4
- old
+ new
@@ -124,11 +124,18 @@
files = folder.length == 1 \
? assets_opts[:"#{folder[0]}"] \
: assets_opts[:"#{folder[0]}"][:"#{folder[1]}"]
# Create a tag for each individual file
- if !assets_opts[:concat]
+ if assets_opts[:compiled] || assets_opts[:concat]
+ name = assets_opts[:compiled] ? assets_opts[:compiled_name] : assets_opts[:concat_name]
+ name = "#{name}/#{folder.join('-')}"
+ # Generate unique url so middleware knows to check for # compile/concat
+ attrs.unshift("#{attr}=\"/#{path}/#{name}/#{assets_unique_id(type)}.#{type}\"")
+ # Return tag string
+ send("#{type}_assets_tag", attrs.join(' '))
+ else
files.each do |file|
# This allows you to do things like:
# assets_opts[:css] = ['app', './bower/jquery/jquery-min.js']
file.gsub!(/\./, '$2E')
# Add tags to the tags array
@@ -137,16 +144,9 @@
attrs.dup.unshift( "#{attr}=\"/#{path}/#{file}.#{type}\"").join(' ')
)
end
# Return tags as string
tags.join "\n"
- else
- name = assets_opts[:compiled] ? assets_opts[:compiled_name] : assets_opts[:concat_name]
- name = "#{name}/#{folder.join('-')}"
- # Generate unique url so middleware knows to check for # compile/concat
- attrs.unshift("#{attr}=\"/#{path}/#{name}/#{assets_unique_id(type)}.#{type}\"")
- # Return tag string
- send("#{type}_assets_tag", attrs.join(' '))
end
end
def render_asset(file, type)
file.gsub!(/(\$2E|%242E)/, '.')