jekyll-slim 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/History.md +9 -0
- data/README.md +10 -11
- data/jekyll-slim.gemspec +1 -0
- data/lib/jekyll-slim.rb +1 -0
- data/lib/jekyll-slim/tags/slim_partial.rb +50 -0
- data/lib/jekyll-slim/version.rb +1 -1
- data/spec/spec_helper.rb +17 -0
- metadata +27 -5
data/.rspec
ADDED
data/.travis.yml
ADDED
data/History.md
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Jekyll-slim
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/jekyll-slim.png)](http://badge.fury.io/rb/jekyll-slim) [![Dependency Status](https://gemnasium.com/kaishin/jekyll-slim.png)](https://gemnasium.com/kaishin/jekyll-slim) [![Code Climate](https://codeclimate.com/github/kaishin/jekyll-slim.png)](https://codeclimate.com/github/kaishin/jekyll-slim)
|
4
|
+
|
3
5
|
A gem that adds [slim-lang](http://slim-lang.com) support to [Jekyll](http://github.com/mojombo/jekyll). Works for for pages, includes and layouts.
|
4
6
|
|
5
7
|
## Installation
|
@@ -27,7 +29,7 @@ In your Jekyll project's `_plugins` directory:
|
|
27
29
|
|
28
30
|
The gem will convert all the `.slim` files in your project's directory into HTML. That includes files in sub-directories, includes and layouts. Example:
|
29
31
|
|
30
|
-
```
|
32
|
+
```haml
|
31
33
|
# _layouts/default.slim
|
32
34
|
html
|
33
35
|
head
|
@@ -35,23 +37,20 @@ html
|
|
35
37
|
.content-wrapper
|
36
38
|
| {{ content }}
|
37
39
|
```
|
40
|
+
To include a partial, use the `slim` liquid tag instead of `include`:
|
38
41
|
|
39
|
-
|
40
|
-
```
|
42
|
+
```haml
|
41
43
|
# index.slim
|
42
44
|
---
|
43
45
|
layout: default
|
44
46
|
---
|
45
47
|
|
46
|
-
section.content
|
47
|
-
|
48
|
+
section.content Content goes here.
|
49
|
+
| {% slim footer.slim %}
|
48
50
|
|
49
51
|
```
|
50
52
|
|
51
|
-
##
|
53
|
+
## Credit
|
54
|
+
|
55
|
+
Jekyll-slim was heavily inspired by [jekyll-haml](https://github.com/samvincent/jekyll-haml). It is free software, and may be redistributed under the terms specified in the LICENSE file.
|
52
56
|
|
53
|
-
1. Fork it
|
54
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
55
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
56
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
57
|
-
5. Create new Pull Request
|
data/jekyll-slim.gemspec
CHANGED
data/lib/jekyll-slim.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'slim'
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class SlimPartialTag < Liquid::Tag
|
5
|
+
def initialize(tag_name, file, tokens)
|
6
|
+
super
|
7
|
+
@file = file.strip
|
8
|
+
end
|
9
|
+
|
10
|
+
def render(context)
|
11
|
+
includes_dir = File.join(context.registers[:site].source, '_includes')
|
12
|
+
|
13
|
+
if File.symlink?(includes_dir)
|
14
|
+
return "Includes directory '#{includes_dir}' cannot be a symlink"
|
15
|
+
end
|
16
|
+
|
17
|
+
if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./
|
18
|
+
return "Include file '#{@file}' contains invalid characters or sequences"
|
19
|
+
end
|
20
|
+
|
21
|
+
return "File must have \".slim\" extension" if @file !~ /\.slim$/
|
22
|
+
|
23
|
+
Dir.chdir(includes_dir) do
|
24
|
+
choices = Dir['**/*'].reject { |x| File.symlink?(x) }
|
25
|
+
if choices.include?(@file)
|
26
|
+
source = File.read(@file)
|
27
|
+
conversion = ::Slim::Template.new{ source }.render
|
28
|
+
partial = Liquid::Template.parse(conversion)
|
29
|
+
begin
|
30
|
+
return partial.render!(context)
|
31
|
+
rescue => e
|
32
|
+
puts "Liquid Exception: #{e.message} in #{self.data["layout"]}"
|
33
|
+
e.backtrace.each do |backtrace|
|
34
|
+
puts backtrace
|
35
|
+
end
|
36
|
+
abort("Build Failed")
|
37
|
+
end
|
38
|
+
|
39
|
+
context.stack do
|
40
|
+
return partial.render(context)
|
41
|
+
end
|
42
|
+
else
|
43
|
+
"Included file '#{@file}' not found in _includes directory"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
Liquid::Template.register_tag('slim', Jekyll::SlimPartialTag)
|
data/lib/jekyll-slim/version.rb
CHANGED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-slim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jekyll
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
78
94
|
description: Slim html converter for Jekyll
|
79
95
|
email:
|
80
96
|
- reda@thoughtbot.com
|
@@ -83,14 +99,19 @@ extensions: []
|
|
83
99
|
extra_rdoc_files: []
|
84
100
|
files:
|
85
101
|
- .gitignore
|
102
|
+
- .rspec
|
103
|
+
- .travis.yml
|
86
104
|
- Gemfile
|
105
|
+
- History.md
|
87
106
|
- LICENSE.txt
|
88
107
|
- README.md
|
89
108
|
- Rakefile
|
90
109
|
- jekyll-slim.gemspec
|
91
110
|
- lib/jekyll-slim.rb
|
92
111
|
- lib/jekyll-slim/ext/convertible.rb
|
112
|
+
- lib/jekyll-slim/tags/slim_partial.rb
|
93
113
|
- lib/jekyll-slim/version.rb
|
114
|
+
- spec/spec_helper.rb
|
94
115
|
homepage: ''
|
95
116
|
licenses: []
|
96
117
|
post_install_message:
|
@@ -105,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
126
|
version: '0'
|
106
127
|
segments:
|
107
128
|
- 0
|
108
|
-
hash:
|
129
|
+
hash: -3054739146948184044
|
109
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
131
|
none: false
|
111
132
|
requirements:
|
@@ -114,11 +135,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
135
|
version: '0'
|
115
136
|
segments:
|
116
137
|
- 0
|
117
|
-
hash:
|
138
|
+
hash: -3054739146948184044
|
118
139
|
requirements: []
|
119
140
|
rubyforge_project:
|
120
141
|
rubygems_version: 1.8.25
|
121
142
|
signing_key:
|
122
143
|
specification_version: 3
|
123
144
|
summary: Slim-lang support for Jekyll. Handles includes and layouts as well.
|
124
|
-
test_files:
|
145
|
+
test_files:
|
146
|
+
- spec/spec_helper.rb
|