staticmatic 0.11.0.alpha.6 → 0.11.0.alpha.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/staticmatic/helpers.rb +6 -4
- data/lib/staticmatic/mixins/render.rb +14 -10
- data/lib/staticmatic/template_error.rb +7 -3
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/staticmatic/helpers.rb
CHANGED
@@ -27,7 +27,7 @@ module StaticMatic
|
|
27
27
|
# Bit of a hack here - adds any stylesheets that exist in the site/ dir that haven't been generated from source sass
|
28
28
|
Dir[File.join(@staticmatic.site_dir, 'stylesheets', '*.css')].each do |filename|
|
29
29
|
search_filename = File.basename(filename).chomp(File.extname(filename))
|
30
|
-
|
30
|
+
puts search_filename
|
31
31
|
already_included = false
|
32
32
|
stylesheet_directories.each do |path|
|
33
33
|
if File.basename(path).include?(search_filename)
|
@@ -44,9 +44,11 @@ module StaticMatic
|
|
44
44
|
filename_without_extension = File.basename(path).chomp(File.extname(path))
|
45
45
|
|
46
46
|
if !filename_without_extension.match(/^\_/)
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
|
48
|
+
path = path.gsub(/#{@staticmatic.src_dir}/, "").
|
49
|
+
gsub(/#{@staticmatic.site_dir}/, "").
|
50
|
+
gsub(/#{filename_without_extension}\.(sass|scss|css)/, "")
|
51
|
+
|
50
52
|
options[:href] = "#{relative_path}#{path}#{filename_without_extension}.css"
|
51
53
|
output << tag(:link, options)
|
52
54
|
end
|
@@ -80,17 +80,21 @@ module StaticMatic::RenderMixin
|
|
80
80
|
# full_file_path = File.join(@src_dir, 'stylesheets', source_dir, "#{source}.sass")
|
81
81
|
full_file_path = Dir[File.join(@src_dir, 'stylesheets', source_dir, "#{source}.{sass,scss}")].first
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
if File.extname(full_file_path) == ".scss"
|
87
|
-
sass_options[:syntax] = :scss
|
88
|
-
end
|
83
|
+
if full_file_path && File.exist?(full_file_path)
|
84
|
+
begin
|
85
|
+
sass_options = { :load_paths => [ File.join(@src_dir, 'stylesheets') ] }.merge(self.configuration.sass_options)
|
89
86
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
87
|
+
if File.extname(full_file_path) == ".scss"
|
88
|
+
sass_options[:syntax] = :scss
|
89
|
+
end
|
90
|
+
|
91
|
+
stylesheet = Sass::Engine.new(File.read(full_file_path), sass_options)
|
92
|
+
stylesheet.to_css
|
93
|
+
rescue Exception => e
|
94
|
+
render_rescue_from_error(StaticMatic::TemplateError.new(full_file_path, e))
|
95
|
+
end
|
96
|
+
else
|
97
|
+
raise StaticMatic::Error.new("", source, "Stylesheet not found")
|
94
98
|
end
|
95
99
|
end
|
96
100
|
|
@@ -6,13 +6,17 @@ class StaticMatic::TemplateError < StandardError
|
|
6
6
|
def initialize(template, original_exception)
|
7
7
|
@template, @original_exception = template, original_exception
|
8
8
|
@backtrace = original_exception.backtrace
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
if template
|
11
|
+
@source = File.read(template)
|
12
|
+
else
|
13
|
+
@source = ""
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
# TODO: Replace 'haml|sass' with any registered engines
|
14
18
|
def line_number
|
15
|
-
@line_number ||= $2 if backtrace.find { |line| line =~ /\((haml|sass)\)\:(\d+)/ }
|
19
|
+
@line_number ||= $2 if backtrace.find { |line| line =~ /\((haml|sass|scss)\)\:(\d+)/ }
|
16
20
|
end
|
17
21
|
|
18
22
|
def filename
|