lib/staticmatic/mixins/render.rb in staticmatic-0.11.0.alpha.6 vs lib/staticmatic/mixins/render.rb in staticmatic-0.11.0.alpha.7
- old
+ new
@@ -78,20 +78,24 @@
def generate_css(source, source_dir = '')
# full_file_path = File.join(@src_dir, 'stylesheets', source_dir, "#{source}.sass")
full_file_path = Dir[File.join(@src_dir, 'stylesheets', source_dir, "#{source}.{sass,scss}")].first
- begin
- sass_options = { :load_paths => [ File.join(@src_dir, 'stylesheets') ] }.merge(self.configuration.sass_options)
-
- if File.extname(full_file_path) == ".scss"
- sass_options[:syntax] = :scss
- end
+ if full_file_path && File.exist?(full_file_path)
+ begin
+ sass_options = { :load_paths => [ File.join(@src_dir, 'stylesheets') ] }.merge(self.configuration.sass_options)
- stylesheet = Sass::Engine.new(File.read(full_file_path), sass_options)
- stylesheet.to_css
- rescue Exception => e
- render_rescue_from_error(StaticMatic::TemplateError.new(full_file_path, e))
+ if File.extname(full_file_path) == ".scss"
+ sass_options[:syntax] = :scss
+ end
+
+ stylesheet = Sass::Engine.new(File.read(full_file_path), sass_options)
+ stylesheet.to_css
+ rescue Exception => e
+ render_rescue_from_error(StaticMatic::TemplateError.new(full_file_path, e))
+ end
+ else
+ raise StaticMatic::Error.new("", source, "Stylesheet not found")
end
end
# Generates html from the passed source string
#
\ No newline at end of file