48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/spiderfw/templates/resources/sass.rb', line 48
def compile(src, dest)
use_compass = false
if Spider.conf.get('css.sass.use_compass')
begin
require 'compass'
use_compass = true
rescue LoadError => exc
Spider.logger.debug(exc)
Spider.logger.debug("Compass not found. Please install 'compass' gem")
end
end
if use_compass
work_dir = FileUtils.mkdir_p(File.join(Spider.paths[:tmp], 'sass'))
src_dir = File.dirname(src)
src_dir = src_dir
sass_options = Compass.sass_engine_options.merge({
:cache_location => File.join(work_dir, '.sass_cache')
})
Spider.app_paths.each do |path|
sass_options[:load_paths] << SassAppImporter.new(path)
end
options = {
:project_path => @base_path,
:css_dir => 'css',
:sass_dir => 'sass',
:fonts_dir => 'fonts',
:images_dir => 'img',
:javascripts_dir => 'js',
:relative_assets => true,
:line_comments => Spider.runmode == 'devel' ? true : false,
:sass => sass_options,
:css_filename => dest
}
config = Compass::Configuration::Data.new(:spider, options)
Compass.add_project_configuration(config)
compiler = Compass::Compiler.new(work_dir, File.dirname(src), File.dirname(dest), options)
compiler.run
else
engine = Sass::Engine.for_file(src, {})
output = engine.render
File.open(dest, 'w') do |f|
f.write "/* This file is autogenerated; do not edit directly (edit #{src} instead) */\n\n"
f.write output
end
end
end
|