Class: Jekyll::Converters::Scss
- Inherits:
-
Converter
- Object
- Converter
- Jekyll::Converters::Scss
- Defined in:
- lib/jekyll/converters/scss.rb
Direct Known Subclasses
Constant Summary collapse
- SyntaxError =
Class.new(ArgumentError)
- ALLOWED_STYLES =
%w(nested expanded compact compressed).freeze
Instance Method Summary collapse
- #allow_caching? ⇒ Boolean
- #convert(content) ⇒ Object
- #jekyll_sass_configuration ⇒ Object
- #matches(ext) ⇒ Object
- #output_ext(ext) ⇒ Object
- #safe? ⇒ Boolean
- #sass_build_configuration_options(overrides) ⇒ Object
- #sass_configs ⇒ Object
- #sass_dir ⇒ Object
- #sass_dir_relative_to_site_source ⇒ Object
- #sass_load_paths ⇒ Object
- #sass_style ⇒ Object
- #syntax ⇒ Object
- #user_sass_load_paths ⇒ Object
Instance Method Details
#allow_caching? ⇒ Boolean
82 83 84 |
# File 'lib/jekyll/converters/scss.rb', line 82 def allow_caching? !safe? end |
#convert(content) ⇒ Object
94 95 96 97 98 |
# File 'lib/jekyll/converters/scss.rb', line 94 def convert(content) ::Sass.compile(content, sass_configs) rescue ::Sass::SyntaxError => e raise SyntaxError.new("#{e.to_s} on line #{e.sass_line}") end |
#jekyll_sass_configuration ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/jekyll/converters/scss.rb', line 26 def jekyll_sass_configuration = @config["sass"] || {} unless ["style"].nil? ["style"] = ["style"].to_s.gsub(/\A:/, '').to_sym end end |
#matches(ext) ⇒ Object
14 15 16 |
# File 'lib/jekyll/converters/scss.rb', line 14 def matches(ext) ext =~ /^\.scss$/i end |
#output_ext(ext) ⇒ Object
18 19 20 |
# File 'lib/jekyll/converters/scss.rb', line 18 def output_ext(ext) ".css" end |
#safe? ⇒ Boolean
22 23 24 |
# File 'lib/jekyll/converters/scss.rb', line 22 def safe? !!@config["safe"] end |
#sass_build_configuration_options(overrides) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/jekyll/converters/scss.rb', line 34 def (overrides) if safe? { :load_paths => sass_load_paths, :syntax => syntax, :style => sass_style, :cache => false } else Jekyll::Utils.symbolize_hash_keys( Jekyll::Utils.deep_merge_hashes( jekyll_sass_configuration, overrides ) ) end end |
#sass_configs ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/jekyll/converters/scss.rb', line 86 def sass_configs ({ "syntax" => syntax, "cache" => allow_caching?, "load_paths" => sass_load_paths }) end |
#sass_dir ⇒ Object
56 57 58 59 |
# File 'lib/jekyll/converters/scss.rb', line 56 def sass_dir return "_sass" if jekyll_sass_configuration["sass_dir"].to_s.empty? jekyll_sass_configuration["sass_dir"] end |
#sass_dir_relative_to_site_source ⇒ Object
70 71 72 |
# File 'lib/jekyll/converters/scss.rb', line 70 def sass_dir_relative_to_site_source Jekyll.sanitized_path(@config["source"], sass_dir) end |
#sass_load_paths ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/jekyll/converters/scss.rb', line 74 def sass_load_paths if safe? [sass_dir_relative_to_site_source] else (user_sass_load_paths + [sass_dir_relative_to_site_source]).uniq end.select { |load_path| File.directory?(load_path) } end |
#sass_style ⇒ Object
61 62 63 64 |
# File 'lib/jekyll/converters/scss.rb', line 61 def sass_style style = jekyll_sass_configuration.fetch("style", :compact) ALLOWED_STYLES.include?(style.to_s) ? style.to_sym : :compact end |
#syntax ⇒ Object
52 53 54 |
# File 'lib/jekyll/converters/scss.rb', line 52 def syntax :scss end |
#user_sass_load_paths ⇒ Object
66 67 68 |
# File 'lib/jekyll/converters/scss.rb', line 66 def user_sass_load_paths Array(jekyll_sass_configuration["load_paths"]) end |