jekyll-contentblocks 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Appraisals +39 -0
- data/Gemfile +5 -0
- data/README.md +17 -0
- data/Rakefile +19 -1
- data/gemfiles/jekyll_1.0.4.gemfile +8 -0
- data/gemfiles/jekyll_1.1.2.gemfile +8 -0
- data/gemfiles/jekyll_1.2.1.gemfile +8 -0
- data/gemfiles/jekyll_1.3.1.gemfile +8 -0
- data/gemfiles/jekyll_1.4.3.gemfile +8 -0
- data/gemfiles/jekyll_1.5.1.gemfile +8 -0
- data/gemfiles/jekyll_2.0.3.gemfile +8 -0
- data/gemfiles/jekyll_2.1.1.gemfile +8 -0
- data/gemfiles/jekyll_2.2.0.gemfile +8 -0
- data/gemfiles/jekyll_2.3.0.gemfile +8 -0
- data/lib/jekyll-contentblocks/common.rb +0 -2
- data/lib/jekyll-contentblocks/content_block.rb +5 -2
- data/lib/jekyll-contentblocks/content_for.rb +0 -1
- data/lib/jekyll-contentblocks/convertible.rb +17 -2
- data/lib/jekyll-contentblocks/version.rb +1 -1
- data/test/_layouts/default.html +12 -0
- data/test/_plugins/bundler.rb +4 -0
- data/test/index.md +13 -0
- metadata +27 -14
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 12919f1fc09805b1f3e91fc6b07841d81ce0ee7a
|
4
|
+
data.tar.gz: 064630ea1d99604218612fb556e3d56e32d50c53
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dfc73df1ae4ca609ea1dc322c0c8b0cd46ccff53df8422650117343b8ac8ae2c582403eaee02d67aaf6aac8bd006263e6a82f5f17f46714a85a43c005def225e
|
7
|
+
data.tar.gz: 9243aeba1dde031fc24879c4a602e2842c277c45125cf02255871e57ca829c452fb7e7aa0d9aead97373d3f84c7c437249427804a8e47be9a02f6a7419b12999
|
data/.gitignore
CHANGED
data/Appraisals
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
appraise "jekyll-1.0.4" do
|
2
|
+
gem "jekyll", "1.0.4"
|
3
|
+
end
|
4
|
+
|
5
|
+
appraise "jekyll-1.1.2" do
|
6
|
+
gem "jekyll", "1.1.2"
|
7
|
+
end
|
8
|
+
|
9
|
+
appraise "jekyll-1.2.1" do
|
10
|
+
gem "jekyll", "1.2.1"
|
11
|
+
end
|
12
|
+
|
13
|
+
appraise "jekyll-1.3.1" do
|
14
|
+
gem "jekyll", "1.3.1"
|
15
|
+
end
|
16
|
+
|
17
|
+
appraise "jekyll-1.4.3" do
|
18
|
+
gem "jekyll", "1.4.3"
|
19
|
+
end
|
20
|
+
|
21
|
+
appraise "jekyll-1.5.1" do
|
22
|
+
gem "jekyll", "1.5.1"
|
23
|
+
end
|
24
|
+
|
25
|
+
appraise "jekyll-2.0.3" do
|
26
|
+
gem "jekyll", "2.0.3"
|
27
|
+
end
|
28
|
+
|
29
|
+
appraise "jekyll-2.1.1" do
|
30
|
+
gem "jekyll", "2.1.1"
|
31
|
+
end
|
32
|
+
|
33
|
+
appraise "jekyll-2.2.0" do
|
34
|
+
gem "jekyll", "2.2.0"
|
35
|
+
end
|
36
|
+
|
37
|
+
appraise "jekyll-2.3.0" do
|
38
|
+
gem "jekyll", "2.3.0"
|
39
|
+
end
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -74,6 +74,23 @@ Here is my post content.
|
|
74
74
|
|
75
75
|
Note that we didn't add anything to the `scripts` block in the post. That's OK, content blocks without any content will be ignored.
|
76
76
|
|
77
|
+
### Checking if contentblock exists
|
78
|
+
|
79
|
+
We might want to check if the particular contentblock exists before using it in our template:
|
80
|
+
|
81
|
+
* [Capture](http://docs.shopify.com/themes/liquid-basics/logic) contents of the `sidebar` contentblock to a variable `result`
|
82
|
+
* If `result` is not empty, output its contents surrounded with desired markup
|
83
|
+
|
84
|
+
```liquid
|
85
|
+
{% capture result %}{% contentblock sidebar %}{% endcapture %}
|
86
|
+
|
87
|
+
{% if result != '' %}
|
88
|
+
...template markup...
|
89
|
+
{{ result }}
|
90
|
+
...template markup...
|
91
|
+
{% endif %}
|
92
|
+
```
|
93
|
+
|
77
94
|
## Contributing
|
78
95
|
|
79
96
|
1. Fork it
|
data/Rakefile
CHANGED
@@ -1 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
desc 'Run the test'
|
6
|
+
task :test do
|
7
|
+
require 'jekyll'
|
8
|
+
system 'rm -rf test/_site'
|
9
|
+
version = `jekyll --version`.strip
|
10
|
+
system 'jekyll build -s test/ -d test/_site &> /dev/null'
|
11
|
+
unless system 'grep \'<h2 id=.sidebar.>SIDEBAR</h2>\' test/_site/index.html &> /dev/null'
|
12
|
+
fail "#{version} failed!"
|
13
|
+
end
|
14
|
+
unless system 'grep "<p>3</p>" test/_site/index.html &> /dev/null'
|
15
|
+
fail "#{version} failed!"
|
16
|
+
end
|
17
|
+
puts "#{version} pass!"
|
18
|
+
end
|
19
|
+
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Jekyll
|
2
2
|
module ContentBlocks
|
3
3
|
module Common
|
4
|
-
# Extracts and verified the content block's name
|
5
4
|
def get_content_block_name(tag_name, block_name)
|
6
5
|
block_name = (block_name || '').strip
|
7
6
|
if block_name == ''
|
@@ -10,7 +9,6 @@ module Jekyll
|
|
10
9
|
block_name
|
11
10
|
end
|
12
11
|
|
13
|
-
# Gets the storage space for the content block
|
14
12
|
def content_for_block(context)
|
15
13
|
context.environments.first['contentblocks'] ||= {}
|
16
14
|
context.environments.first['contentblocks'][@block_name] ||= []
|
@@ -9,8 +9,11 @@ module Jekyll
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def render(context)
|
12
|
-
|
13
|
-
|
12
|
+
block_content = content_for_block(context).join
|
13
|
+
converters = context.environments.first['converters']
|
14
|
+
converters.reduce(block_content) do |content, converter|
|
15
|
+
converter.convert(content)
|
16
|
+
end
|
14
17
|
end
|
15
18
|
end
|
16
19
|
end
|
@@ -3,10 +3,25 @@ module Jekyll
|
|
3
3
|
alias_method :do_layout_orig, :do_layout
|
4
4
|
|
5
5
|
def do_layout(payload, layouts)
|
6
|
-
|
7
|
-
payload['converter'] = self.converter
|
6
|
+
payload['converters'] = converters_for_content_block
|
8
7
|
payload['contentblocks'] = {}
|
9
8
|
do_layout_orig(payload, layouts)
|
10
9
|
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def converters_for_content_block
|
14
|
+
if jekyll_version_less_than?('2.3.0')
|
15
|
+
[converter]
|
16
|
+
else
|
17
|
+
converters.reject do |converter|
|
18
|
+
converter.class == Jekyll::Converters::Identity
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def jekyll_version_less_than?(version)
|
24
|
+
Gem::Version.new(Jekyll::VERSION) < Gem::Version.new(version)
|
25
|
+
end
|
11
26
|
end
|
12
27
|
end
|
data/test/index.md
ADDED
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-contentblocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Rusty Geldmacher
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: jekyll
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
description: Provides a mechanism for passing content up to the layout, like Rails'
|
@@ -36,10 +33,21 @@ extensions: []
|
|
36
33
|
extra_rdoc_files: []
|
37
34
|
files:
|
38
35
|
- .gitignore
|
36
|
+
- Appraisals
|
39
37
|
- Gemfile
|
40
38
|
- LICENSE.txt
|
41
39
|
- README.md
|
42
40
|
- Rakefile
|
41
|
+
- gemfiles/jekyll_1.0.4.gemfile
|
42
|
+
- gemfiles/jekyll_1.1.2.gemfile
|
43
|
+
- gemfiles/jekyll_1.2.1.gemfile
|
44
|
+
- gemfiles/jekyll_1.3.1.gemfile
|
45
|
+
- gemfiles/jekyll_1.4.3.gemfile
|
46
|
+
- gemfiles/jekyll_1.5.1.gemfile
|
47
|
+
- gemfiles/jekyll_2.0.3.gemfile
|
48
|
+
- gemfiles/jekyll_2.1.1.gemfile
|
49
|
+
- gemfiles/jekyll_2.2.0.gemfile
|
50
|
+
- gemfiles/jekyll_2.3.0.gemfile
|
43
51
|
- jekyll-contentblocks.gemspec
|
44
52
|
- lib/jekyll-contentblocks.rb
|
45
53
|
- lib/jekyll-contentblocks/common.rb
|
@@ -47,28 +55,33 @@ files:
|
|
47
55
|
- lib/jekyll-contentblocks/content_for.rb
|
48
56
|
- lib/jekyll-contentblocks/convertible.rb
|
49
57
|
- lib/jekyll-contentblocks/version.rb
|
58
|
+
- test/_layouts/default.html
|
59
|
+
- test/_plugins/bundler.rb
|
60
|
+
- test/index.md
|
50
61
|
homepage: https://github.com/rustygeldmacher/jekyll-contentblocks
|
51
62
|
licenses: []
|
63
|
+
metadata: {}
|
52
64
|
post_install_message:
|
53
65
|
rdoc_options: []
|
54
66
|
require_paths:
|
55
67
|
- lib
|
56
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
69
|
requirements:
|
59
|
-
- -
|
70
|
+
- - '>='
|
60
71
|
- !ruby/object:Gem::Version
|
61
72
|
version: '0'
|
62
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
74
|
requirements:
|
65
|
-
- -
|
75
|
+
- - '>='
|
66
76
|
- !ruby/object:Gem::Version
|
67
77
|
version: '0'
|
68
78
|
requirements: []
|
69
79
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.
|
80
|
+
rubygems_version: 2.1.11
|
71
81
|
signing_key:
|
72
|
-
specification_version:
|
82
|
+
specification_version: 4
|
73
83
|
summary: A Jekyll plugin kind of like Rails' content_for
|
74
|
-
test_files:
|
84
|
+
test_files:
|
85
|
+
- test/_layouts/default.html
|
86
|
+
- test/_plugins/bundler.rb
|
87
|
+
- test/index.md
|