jekyll-contentblocks 1.1.0 → 1.2.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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/Appraisals +8 -0
- data/Gemfile +1 -1
- data/README.md +5 -10
- data/gemfiles/jekyll_3.0.3.gemfile +12 -0
- data/gemfiles/jekyll_3.1.2.gemfile +12 -0
- data/lib/jekyll-contentblocks.rb +12 -3
- data/lib/jekyll/content_blocks/pre_render_hook.rb +13 -0
- data/lib/jekyll/content_blocks/version.rb +1 -1
- data/spec/jekyll_content_blocks_spec.rb +10 -1
- data/test/_plugins/require.rb +2 -0
- data/test/page2.md +12 -0
- metadata +10 -4
- data/test/_plugins/bundler.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40a997daa68a6ef8db0f0df0125d379c4a8fe962
|
4
|
+
data.tar.gz: ebafec9066fba596044477ede027e556c92de9b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb02de9135f264125157e2b0412ac3ab5b10234144f6c16e5300ee3e23adba036e9ca1ce20f90fb9ff37d966c044b6567317275757c16880aafa757a16ea2955
|
7
|
+
data.tar.gz: 39869c8dc1f4c427b17ce2fd1f4a128571ed8b00200d7c84ddeb6d32dd3f99e2aa070795e16ba9ff463f427295e78a37540ba2f947fbbc5c2651c8ff4a5e2a6a
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.1
|
data/Appraisals
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -9,7 +9,9 @@ layouts. It's kind of like having Rails' content_for available for Jekyll.
|
|
9
9
|
|
10
10
|
Add this line to your Jekyll project's `Gemfile`:
|
11
11
|
```ruby
|
12
|
-
|
12
|
+
group :jekyll_plugins do
|
13
|
+
gem 'jekyll-contentblocks'
|
14
|
+
end
|
13
15
|
```
|
14
16
|
|
15
17
|
Then execute:
|
@@ -17,15 +19,8 @@ Then execute:
|
|
17
19
|
$ bundle install
|
18
20
|
```
|
19
21
|
|
20
|
-
Make sure your have a plugin that initializes Bundler:
|
21
|
-
```ruby
|
22
|
-
# _plugins/bundler.rb
|
23
|
-
require "rubygems"
|
24
|
-
require "bundler/setup"
|
25
|
-
Bundler.require(:default)
|
26
|
-
```
|
27
|
-
|
28
22
|
### Standalone
|
23
|
+
|
29
24
|
Execute:
|
30
25
|
```bash
|
31
26
|
$ gem install jekyll-contentblocks
|
@@ -101,7 +96,7 @@ it in our template. To do this, use the `ifhascontent` tag:
|
|
101
96
|
```liquid
|
102
97
|
{% ifhascontent javascripts %}
|
103
98
|
<script type="text/javascript>
|
104
|
-
{%
|
99
|
+
{% contentblock javascripts %}
|
105
100
|
</script>
|
106
101
|
{% endifhascontent %}
|
107
102
|
```
|
data/lib/jekyll-contentblocks.rb
CHANGED
@@ -10,9 +10,18 @@ module Jekyll
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
if Jekyll.version_less_than?('3.0.0')
|
14
|
+
require 'jekyll/content_blocks/convertible'
|
15
|
+
unless Jekyll.version_less_than?('2.0.0')
|
16
|
+
require 'jekyll/content_blocks/renderer'
|
17
|
+
end
|
18
|
+
else
|
19
|
+
require 'jekyll/content_blocks/pre_render_hook'
|
20
|
+
[:documents, :pages, :posts].each do |content_type|
|
21
|
+
Jekyll::Hooks.register content_type, :pre_render do |doc, payload|
|
22
|
+
Jekyll::ContentBlocks::PreRenderHook.call(doc, payload)
|
23
|
+
end
|
24
|
+
end
|
16
25
|
end
|
17
26
|
|
18
27
|
require 'jekyll/content_blocks/version'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module ContentBlocks
|
3
|
+
class PreRenderHook
|
4
|
+
def self.call(document, payload)
|
5
|
+
payload['converters'] = document.site.converters.select do |converter|
|
6
|
+
file_extension = File.extname(document.path)
|
7
|
+
converter.matches(file_extension)
|
8
|
+
end
|
9
|
+
payload['contentblocks'] = {}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -40,7 +40,6 @@ describe Jekyll::ContentBlocks do
|
|
40
40
|
|
41
41
|
describe 'page.html' do
|
42
42
|
let(:page) { load_html('page.html') }
|
43
|
-
let(:sidebar) { index.css('body > div > h2#sidebar').first }
|
44
43
|
|
45
44
|
it 'renders the css block' do
|
46
45
|
expect(page.css('style')).not_to be_empty
|
@@ -62,6 +61,16 @@ describe Jekyll::ContentBlocks do
|
|
62
61
|
end
|
63
62
|
end
|
64
63
|
|
64
|
+
describe 'page2.html' do
|
65
|
+
let(:page) { load_html('page2.html') }
|
66
|
+
|
67
|
+
it 'renders only the page2 sidebar' do
|
68
|
+
sidebar = page.css('div.custom-sidebar')
|
69
|
+
expect(sidebar).not_to be_empty
|
70
|
+
expect(sidebar.text.strip).to eq 'A pretty simple sidebar.'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
65
74
|
describe 'ifnothascontent' do
|
66
75
|
it 'renders defaults when content is not supplied' do
|
67
76
|
expect(index.css('div#footer')).not_to be_empty
|
data/test/page2.md
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-contentblocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rusty Geldmacher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -33,6 +33,7 @@ extensions: []
|
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
35
|
- ".gitignore"
|
36
|
+
- ".ruby-version"
|
36
37
|
- Appraisals
|
37
38
|
- Gemfile
|
38
39
|
- LICENSE.txt
|
@@ -50,10 +51,13 @@ files:
|
|
50
51
|
- gemfiles/jekyll_2.3.0.gemfile
|
51
52
|
- gemfiles/jekyll_2.4.0.gemfile
|
52
53
|
- gemfiles/jekyll_2.5.3.gemfile
|
54
|
+
- gemfiles/jekyll_3.0.3.gemfile
|
55
|
+
- gemfiles/jekyll_3.1.2.gemfile
|
53
56
|
- jekyll-contentblocks.gemspec
|
54
57
|
- lib/jekyll-contentblocks.rb
|
55
58
|
- lib/jekyll/content_blocks/content_block_tag.rb
|
56
59
|
- lib/jekyll/content_blocks/convertible.rb
|
60
|
+
- lib/jekyll/content_blocks/pre_render_hook.rb
|
57
61
|
- lib/jekyll/content_blocks/renderer.rb
|
58
62
|
- lib/jekyll/content_blocks/version.rb
|
59
63
|
- lib/jekyll/tags/content_block.rb
|
@@ -66,9 +70,10 @@ files:
|
|
66
70
|
- test/_items/one.md
|
67
71
|
- test/_items/two.md
|
68
72
|
- test/_layouts/default.html
|
69
|
-
- test/_plugins/
|
73
|
+
- test/_plugins/require.rb
|
70
74
|
- test/index.md
|
71
75
|
- test/page.md
|
76
|
+
- test/page2.md
|
72
77
|
homepage: https://github.com/rustygeldmacher/jekyll-contentblocks
|
73
78
|
licenses: []
|
74
79
|
metadata: {}
|
@@ -99,6 +104,7 @@ test_files:
|
|
99
104
|
- test/_items/one.md
|
100
105
|
- test/_items/two.md
|
101
106
|
- test/_layouts/default.html
|
102
|
-
- test/_plugins/
|
107
|
+
- test/_plugins/require.rb
|
103
108
|
- test/index.md
|
104
109
|
- test/page.md
|
110
|
+
- test/page2.md
|
data/test/_plugins/bundler.rb
DELETED