ace: uniq generating files. SassFilter: sass possible too; instead substitude extention, .scss|.sass will be removed

This commit is contained in:
Denis Knauf 2013-01-19 21:13:15 +01:00
parent 6200acce71
commit 8a5db0714d
2 changed files with 8 additions and 5 deletions

View file

@ -72,7 +72,7 @@ end
unless ARGV.include?("--no-generate") unless ARGV.include?("--no-generate")
puts puts
Ace::Item.all_instances.each do |item| Ace::Item.all_instances.uniq.each do |item|
item.save! item.save!
end end
end end

View file

@ -6,15 +6,18 @@ require "ace/filters"
module Ace module Ace
class SassFilter < Filter class SassFilter < Filter
def call(item, content) def call(item, content)
if item.output_path && item.output_path.end_with?(".scss") if item.output_path && item.output_path.match(/\.s[ac]ss$/)
item.output_path.sub!(/scss$/, "css") syntax = item.output_path.end_with?(".scss") ? :scss : :sass
item.output_path.sub!(/\.s[ac]ss$/, '')
output = nil
begin begin
engine = Sass::Engine.new(content, {:syntax => :scss}) engine = Sass::Engine.new(content, syntax: syntax, filename: item.original_path)
output = engine.render output = engine.render
rescue Exception => e rescue Exception => e
warn "~~ SassFilter exception: #{e}" warn "~~ SassFilter exception: #{e}"
abort abort
end end
#p caller: Kernel.caller
return output return output
else else
return content return content