jekyll-sass 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/jekyll-sass.rb +25 -5
- data/lib/jekyll-sass/version.rb +1 -1
- data/readme.md +17 -9
- metadata +2 -2
data/lib/jekyll-sass.rb
CHANGED
@@ -3,6 +3,21 @@ require "jekyll-sass/version"
|
|
3
3
|
module Jekyll
|
4
4
|
module Sass
|
5
5
|
require 'sass'
|
6
|
+
|
7
|
+
class SassConfig
|
8
|
+
def self.generate()
|
9
|
+
config = Hash["style", :compressed, "syntax", :scss]
|
10
|
+
if Jekyll.configuration({}).has_key?('sass')
|
11
|
+
config.merge!(Jekyll.configuration({})['sass']) {|key,v1,v2| v2.to_sym}
|
12
|
+
end
|
13
|
+
config
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.get()
|
17
|
+
@config ||= generate()
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
6
21
|
class SassCssFile < StaticFile
|
7
22
|
|
8
23
|
# Obtain destination path.
|
@@ -10,14 +25,16 @@ module Jekyll
|
|
10
25
|
#
|
11
26
|
# Returns destination file path.
|
12
27
|
def destination(dest)
|
13
|
-
|
28
|
+
syntax = SassConfig.get()['syntax'].to_s
|
29
|
+
File.join(dest, @dir, @name.sub(/#{syntax}$/, 'css'))
|
14
30
|
end
|
15
31
|
|
16
|
-
# Convert the scss file into a css file.
|
32
|
+
# Convert the sass/scss file into a css file.
|
17
33
|
# +dest+ is the String path to the destination dir
|
18
34
|
#
|
19
35
|
# Returns false if the file was not modified since last time (no-op).
|
20
36
|
def write(dest)
|
37
|
+
config = SassConfig.get()
|
21
38
|
dest_path = destination(dest)
|
22
39
|
|
23
40
|
return false if File.exist? dest_path and !modified?
|
@@ -26,7 +43,7 @@ module Jekyll
|
|
26
43
|
FileUtils.mkdir_p(File.dirname(dest_path))
|
27
44
|
begin
|
28
45
|
content = File.read(path)
|
29
|
-
engine = ::Sass::Engine.new( content, :syntax =>
|
46
|
+
engine = ::Sass::Engine.new( content, :syntax => config['syntax'], :load_paths => ["#{@site.source}#{@dir}"], :style => config['style'] )
|
30
47
|
content = engine.render
|
31
48
|
File.open(dest_path, 'w') do |f|
|
32
49
|
f.write(content)
|
@@ -44,12 +61,13 @@ module Jekyll
|
|
44
61
|
class SassCssGenerator < Generator
|
45
62
|
safe true
|
46
63
|
|
47
|
-
# Jekyll will have already added the *.scss files as Jekyll::StaticFile
|
64
|
+
# Jekyll will have already added the *.sass/scss files as Jekyll::StaticFile
|
48
65
|
# objects to the static_files array. Here we replace those with a
|
49
66
|
# SassCssFile object.
|
50
67
|
def generate(site)
|
68
|
+
syntax = SassConfig.get()['syntax'].to_s
|
51
69
|
site.static_files.clone.each do |sf|
|
52
|
-
if sf.kind_of?(Jekyll::StaticFile) && sf.path =~
|
70
|
+
if sf.kind_of?(Jekyll::StaticFile) && sf.path =~ /\.#{syntax}$/
|
53
71
|
site.static_files.delete(sf)
|
54
72
|
name = File.basename(sf.path)
|
55
73
|
destination = File.dirname(sf.path).sub(site.source, '')
|
@@ -57,6 +75,8 @@ module Jekyll
|
|
57
75
|
end
|
58
76
|
end
|
59
77
|
end
|
78
|
+
|
60
79
|
end
|
80
|
+
|
61
81
|
end
|
62
82
|
end
|
data/lib/jekyll-sass/version.rb
CHANGED
data/readme.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
Sass for Jekyll
|
2
2
|
===============
|
3
3
|
|
4
4
|
This gem provides a [Jekyll](http://github.com/mojombo/jekyll) converter for
|
@@ -10,31 +10,39 @@ Install the gem:
|
|
10
10
|
|
11
11
|
[sudo] gem install jekyll-sass
|
12
12
|
|
13
|
-
In a plugin file within your Jekyll project's _plugins directory:
|
13
|
+
In a plugin file within your Jekyll project's `_plugins` directory:
|
14
14
|
|
15
15
|
# _plugins/my-plugin.rb
|
16
16
|
require "jekyll-sass"
|
17
17
|
|
18
18
|
Place .scss files anywhere in your Jekyll project's directory. These will be
|
19
19
|
converted to .css files with the same directory path and filename. For example,
|
20
|
-
if you create a Less file at
|
21
|
-
css file would end up at
|
20
|
+
if you create a Less file at `css/my-stuff/styles.scss`, then the corresponding
|
21
|
+
css file would end up at `css/my-stuff/styles.css`.
|
22
22
|
|
23
23
|
Bundler Setup
|
24
24
|
-------------
|
25
|
-
|
25
|
+
Using bundler to manage gems for your Jekyll project? Just add
|
26
26
|
|
27
27
|
gem "jekyll-sass"
|
28
28
|
|
29
|
-
to your gemfile and create the following plugin in your projects _plugins
|
30
|
-
directory.
|
31
|
-
of the gems specified in your Gemfile.
|
29
|
+
to your gemfile and create the following plugin in your projects `_plugins`
|
30
|
+
directory. This will automatically require all of the gems specified in your Gemfile.
|
32
31
|
|
33
32
|
# _plugins/bundler.rb
|
34
33
|
require "rubygems"
|
35
34
|
require "bundler/setup"
|
36
35
|
Bundler.require(:default)
|
37
36
|
|
37
|
+
Configuration
|
38
|
+
-------------
|
39
|
+
In your `_config.yml`
|
40
|
+
|
41
|
+
# defaults
|
42
|
+
sass:
|
43
|
+
syntax: scss # scss|sass
|
44
|
+
style: compressed # nested|expanded|compact|compressed
|
45
|
+
|
38
46
|
Credit
|
39
47
|
------
|
40
|
-
This gem is based on [Roger López's](https://github.com/zroger) [jekyll-less](https://github.com/zroger/jekyll-less).
|
48
|
+
This gem is based on [Roger López's](https://github.com/zroger) [jekyll-less](https://github.com/zroger/jekyll-less), with contributions from [Joe Buszkiewic](https://github.com/zznq).
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jekyll-sass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jason Kozak
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-11-20 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: jekyll
|