lib/staticmatic/helpers/assets_helper.rb in staticmatic2-2.0.0 vs lib/staticmatic/helpers/assets_helper.rb in staticmatic2-2.0.1
- old
+ new
@@ -7,11 +7,11 @@
# = stylesheets
# or specific stylesheets in a specific order
# = stylesheets :reset, :application
# Can also pass options hash in at the end so you can specify :media => :print
def stylesheets(*params)
- options = if params.last.is_a? Hash; params.pop else {} end # clean up
+ options = (params.last.is_a? Hash) ? params.pop : {}
options[:media] = 'all' unless options.has_key?(:media)
options[:rel] = 'stylesheet'; options[:type] = 'text/css'
src_files = @staticmatic.src_file_paths('sass','scss','css')
@@ -40,20 +40,19 @@
# Generate javascript source tags for the specified files
#
# javascripts('test') -> <script language="javascript" src="javascripts/test.js"></script>
#
def javascripts(*files)
- options = if files.last.is_a? Hash; files.pop else {} end # clean up
+ options = (files.last.is_a? Hash) ? files.pop : {}
options[:language] = 'javascript'
options[:type] = 'text/javascript'
src_files = @staticmatic.src_file_paths('js','coffee')
output = ""
files.each do |path|
- puts "path: #{path}"
if path.to_s.match %r{^https?://}
output << format_output(:script,path,options)
else
idx = src_files.index do |src|
%w{coffee js}.map {|t| src.match /#{path.to_s}\.#{t}$/ }.any?
@@ -81,11 +80,11 @@
if external_url
src = path
else
filename_without_extension = File.basename(path).chomp(File.extname(path))
- path = path.gsub(/#{@staticmatic.src_dir}/, "").
- gsub(/#{@staticmatic.site_dir}/, "").
+ path = path.gsub(/^#{@staticmatic.src_dir}/, "").
+ gsub(/^#{@staticmatic.site_dir}/, "").
gsub(/#{filename_without_extension}\.(sass|scss|css|js|coffee)/, "")
src = File.join(current_page_relative_path, path, "#{filename_without_extension}")
end