mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00

git-svn-id: svn://hamptoncatlin.com/haml/branches/1.5dev@176 7063305b-7217-0410-af8c-cdc13e5119b9
35 lines
962 B
Ruby
35 lines
962 B
Ruby
|
|
require File.dirname(__FILE__) + "/engine"
|
|
|
|
#Rails plugin stuff. For use with action_view
|
|
|
|
module Sass
|
|
module Plugin
|
|
@@options = {}
|
|
|
|
class << self
|
|
def options; @@options; end
|
|
|
|
def _stylesheet_location
|
|
@@options[:stylesheet_location] || (RAILS_ROOT + "/public/stylesheets/")
|
|
end
|
|
|
|
def _always_update
|
|
@@options[:always_update] || false
|
|
end
|
|
|
|
def stylesheet_needs_update?(file_location)
|
|
!File.exists?(file_location + ".css") || (File.mtime("#{file_location}.sass") - 2) > File.mtime("#{file_location}.css")
|
|
end
|
|
end
|
|
|
|
def sass_template(name)
|
|
file_location = Plugin._stylesheet_location + "/" + name.to_s
|
|
if Plugin._always_update || Plugin.stylesheet_needs_update?(file_location)
|
|
output_file = File.open(file_location + ".css", "w+")
|
|
output_file << Sass::Engine.new.render_file(file_location + ".sass")
|
|
output_file.close
|
|
end
|
|
end
|
|
end
|
|
end
|