octopress-wrap-tag 1.0.0 → 1.0.1
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/{test/.clash.yml → .clash.yml} +0 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +92 -60
- data/assets/docs/index.markdown +58 -43
- data/lib/octopress-wrap-tag.rb +15 -5
- data/lib/octopress-wrap-tag/version.rb +2 -2
- data/octopress-wrap-tag.gemspec +1 -1
- metadata +3 -5
- data/lib/octopress-wrap-tag/ink-plugin.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4de1867426ce69f1af6371588731c959b85de7a8
|
4
|
+
data.tar.gz: 05fa6afb1192fc9121358d89aede084511c38404
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c050cfb7ff9bca567a72718fac7601d41ae3a40e036d0bc3912eea22a92d59ca32bddafefaa05a0c8e146a57e811cedb245f49b444b00b3447d251b0952cf161
|
7
|
+
data.tar.gz: 57cd6af73b84ffb83c840f707a420ddaf97130e83bdcab1eb66fcb7ea42029c1c09f58b49a5cc6a79b2750ac2f597263836e5cdc1e4b39b1b1c4341a4b589e8e
|
File without changes
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -27,100 +27,132 @@ Next add it to your gems list in Jekyll's `_config.yml`
|
|
27
27
|
|
28
28
|
## Usage
|
29
29
|
|
30
|
-
Use this just like the Octopress include, render or yield tags, but wrap the output.
|
31
30
|
|
32
|
-
|
33
|
-
<article>{{ yield }}</article>
|
34
|
-
{% endwrap %}
|
31
|
+
### Basic usage
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
the wrap tag is basically just wrapping Octopress's [include](https://github.com/octopress/include-tag),
|
34
|
+
[render](https://github.com/octopress/render-tag) and [yield](https://github.com/octopress/content-for)
|
35
|
+
tags with HTML in a liquid block tag. So all the features are the same.
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
{% endwrap %}
|
37
|
+
The wrap tag supports all the same features that Octopress's [include](https://github.com/octopress/include-tag),
|
38
|
+
[render](https://github.com/octopress/render-tag) and [yield](https://github.com/octopress/content-for) tags support. This also means that `wrap yield` won't output anything if there isn't any content.
|
43
39
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
```html
|
41
|
+
{% wrap include post.html %}
|
42
|
+
<article>{{ yield }}</article>
|
43
|
+
{% endwrap %}
|
48
44
|
|
49
|
-
|
45
|
+
{% wrap render ../LICENCE.md %}
|
46
|
+
<div class="licence-text">{{ yield }}</div>
|
47
|
+
{% endwrap %}
|
50
48
|
|
51
|
-
|
52
|
-
|
49
|
+
{% wrap yeild post_footer %}
|
50
|
+
<div class="post-footer">{{ yield }}</div>
|
51
|
+
{% endwrap %}
|
52
|
+
```
|
53
53
|
|
54
|
-
|
55
|
-
<aside>{{ yield }}</aside>
|
56
|
-
{% endwrap %}
|
54
|
+
### Yield example
|
57
55
|
|
58
|
-
|
56
|
+
A great use case for `wrap yield` is to add content sections to a
|
57
|
+
template which can be easily and optionally filled from a post or page by using the
|
58
|
+
[content_for](https://github.com/octopress/content-for) tag. Here's an example.
|
59
59
|
|
60
|
-
|
61
|
-
<aside>{{ yield }}</aside>
|
62
|
-
{% endwrap %}
|
60
|
+
<!-- title:"In a page template"-->
|
63
61
|
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
```html
|
63
|
+
<aside class="sidebar">
|
64
|
+
{% wrap yield sidebar_before %}
|
65
|
+
<section>{{ yield }}</section>
|
66
|
+
{% endwrap %}
|
67
67
|
|
68
|
-
|
69
|
-
<aside>{{ yield }}</aside>
|
70
|
-
{% endwrap %}
|
68
|
+
// Regular sidebar content goes here //
|
71
69
|
|
72
|
-
|
70
|
+
{% wrap yield sidebar_after %}
|
71
|
+
<section>{{ yield }}</section>
|
72
|
+
{% endwrap %}
|
73
|
+
</aside>
|
74
|
+
```
|
73
75
|
|
74
|
-
|
75
|
-
{% include foo.html | upcase %} //=> YO, WHAT'S UP
|
76
|
+
Now in any post or page you can add custom content to the sidebar with a content_for tag.
|
76
77
|
|
77
|
-
|
78
|
+
<!-- title:"In a post" -->
|
78
79
|
|
79
|
-
|
80
|
+
```html
|
81
|
+
{% content_for sidebar_before %}
|
82
|
+
<h4>About this post</h4>
|
83
|
+
...
|
84
|
+
{% endcontent_for %}
|
85
|
+
```
|
80
86
|
|
81
|
-
|
87
|
+
This content will appear at the top of the sidebar, wrapped in a `section` element. The `sidebar_after` section won't be
|
88
|
+
rendered since it wasn't set in this post.
|
82
89
|
|
83
|
-
|
90
|
+
### Advanced features
|
84
91
|
|
85
|
-
|
92
|
+
The examples below only demonstrate wrapping the include tag for brevity, but as stated earlier, the wrap tag
|
93
|
+
is basically just wrapping Octopress's [include](https://github.com/octopress/include-tag),
|
94
|
+
[render](https://github.com/octopress/render-tag) and [yield](https://github.com/octopress/content-for)
|
95
|
+
tags with HTML in a liquid block tag. So all the features are the same.
|
86
96
|
|
87
|
-
|
97
|
+
<!-- title:"If a page has this yaml front-matter" -->
|
98
|
+
```html
|
99
|
+
---
|
100
|
+
sidebar: post_sidebar.html
|
101
|
+
---
|
88
102
|
|
89
|
-
|
103
|
+
{% wrap include page.sidebar %}
|
104
|
+
<aside>{{ yield }}</aside>
|
105
|
+
{% endwrap %}
|
106
|
+
```
|
90
107
|
|
91
|
-
|
92
|
-
{% include twitter:feed.html %} // Include the feed from a twitter plugin
|
108
|
+
Include partials conditionally, using `if`, `unless` and ternary logic.
|
93
109
|
|
94
|
-
|
110
|
+
```html
|
111
|
+
{% wrap include page.sidebar if page.sidebar %}
|
112
|
+
<aside>{{ yield }}</aside>
|
113
|
+
{% endwrap %}
|
95
114
|
|
96
|
-
|
97
|
-
|
115
|
+
{% wrap include comments.html unless page.comments == false %}
|
116
|
+
<div class="post-comments">{{ yield }}</div>
|
117
|
+
{% endwrap %}
|
98
118
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
{% endfor %}
|
119
|
+
{% wrap include (post ? post_sidebar : page_sidebar) %}
|
120
|
+
<aside>{{ yield }}</aside>
|
121
|
+
{% endwrap %}
|
122
|
+
```
|
104
123
|
|
124
|
+
Filter included partials.
|
105
125
|
|
106
|
-
|
107
|
-
|
126
|
+
```
|
127
|
+
{% wrap include greeting.html %} yo, {{ yield }}{% endwrap %} //=> yo, what's up?
|
128
|
+
{% wrap include greeting.html %} yo, {{ yield | upcase }}{% endwrap %} //=> yo, WHAT'S UP?
|
129
|
+
{% wrap include greeting.html | upcase %} Yo, {{ yield }}{% endwrap %} //=> YO, WHAT'S UP?
|
130
|
+
```
|
108
131
|
|
109
|
-
Note: To make overriding partials easier, you can copy all of a plugin's partials to your local override path with the Octopress Ink command:
|
110
132
|
|
111
|
-
|
133
|
+
### Include partials with an Octopress Ink plugin.
|
112
134
|
|
113
|
-
|
135
|
+
It's easy to include a partial from an Ink theme or plugin.
|
114
136
|
|
115
|
-
|
137
|
+
Here's the syntax
|
116
138
|
|
117
|
-
|
139
|
+
```
|
140
|
+
{% wrap include [plugin-slug]:[partial-name] %}
|
141
|
+
{{ yield }}
|
142
|
+
{% endwrap %}
|
143
|
+
```
|
118
144
|
|
119
|
-
|
145
|
+
Some examples:
|
120
146
|
|
121
|
-
|
147
|
+
```html
|
148
|
+
{% wrap include theme:sidebar.html %} // Include the sidebar from a theme plugin
|
149
|
+
<aside>{{ yield }}</aside>
|
150
|
+
{% endwrap %}
|
122
151
|
|
123
|
-
|
152
|
+
{% wrap include twitter:feed.html %} // Include the feed from a twitter plugin
|
153
|
+
<div class="twitter-feed">{{ yield }}</div>
|
154
|
+
{% endwrap %}
|
155
|
+
```
|
124
156
|
|
125
157
|
## Contributing
|
126
158
|
|
data/assets/docs/index.markdown
CHANGED
@@ -29,7 +29,15 @@ Next add it to your gems list in Jekyll's `_config.yml`
|
|
29
29
|
|
30
30
|
## Usage
|
31
31
|
|
32
|
-
|
32
|
+
|
33
|
+
### Basic usage
|
34
|
+
|
35
|
+
the wrap tag is basically just wrapping Octopress's [include](https://github.com/octopress/include-tag),
|
36
|
+
[render](https://github.com/octopress/render-tag) and [yield](https://github.com/octopress/content-for)
|
37
|
+
tags with HTML in a liquid block tag. So all the features are the same.
|
38
|
+
|
39
|
+
The wrap tag supports all the same features that Octopress's [include](https://github.com/octopress/include-tag),
|
40
|
+
[render](https://github.com/octopress/render-tag) and [yield](https://github.com/octopress/content-for) tags support. This also means that `wrap yield` won't output anything if there isn't any content.
|
33
41
|
|
34
42
|
{% wrap include post.html %}
|
35
43
|
<article>{{ yield }}</article>
|
@@ -43,12 +51,44 @@ Use this just like the Octopress include, render or yield tags, but wrap the out
|
|
43
51
|
<div class="post-footer">{{ yield }}</div>
|
44
52
|
{% endwrap %}
|
45
53
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
54
|
+
### Yield example
|
55
|
+
|
56
|
+
A great use case for `wrap yield` is to add content sections to a
|
57
|
+
template which can be easily and optionally filled from a post or page by using the
|
58
|
+
[content_for](https://github.com/octopress/content-for) tag. Here's an example.
|
59
|
+
|
60
|
+
// In a page template
|
61
|
+
|
62
|
+
<aside class="sidebar">
|
63
|
+
{% wrap yield sidebar_before %}
|
64
|
+
<section>{{ yield }}</section>
|
65
|
+
{% endwrap %}
|
66
|
+
|
67
|
+
// Regular sidebar content goes here //
|
68
|
+
|
69
|
+
{% wrap yield sidebar_after %}
|
70
|
+
<section>{{ yield }}</section>
|
71
|
+
{% endwrap %}
|
72
|
+
</aside>
|
50
73
|
|
51
|
-
|
74
|
+
Now in any post or page you can add custom content to the sidebar with a content_for tag.
|
75
|
+
|
76
|
+
// In a post
|
77
|
+
|
78
|
+
{% content_for sidebar_before %}
|
79
|
+
<h4>About this post</h4>
|
80
|
+
...
|
81
|
+
{% endcontent_for %}
|
82
|
+
|
83
|
+
This content will appear at the top of the sidebar, wrapped in a `section` element. The `sidebar_after` section won't be
|
84
|
+
rendered since it wasn't set in this post.
|
85
|
+
|
86
|
+
### Advanced features
|
87
|
+
|
88
|
+
The examples below only demonstrate wrapping the include tag for brevity, but as stated earlier, the wrap tag
|
89
|
+
is basically just wrapping Octopress's [include](https://github.com/octopress/include-tag),
|
90
|
+
[render](https://github.com/octopress/render-tag) and [yield](https://github.com/octopress/content-for)
|
91
|
+
tags with HTML in a liquid block tag. So all the features are the same.
|
52
92
|
|
53
93
|
// If a page has the following YAML front-matter
|
54
94
|
// sidebar: post_sidebar.html
|
@@ -73,12 +113,10 @@ Include partials conditionally, using `if`, `unless` and ternary logic.
|
|
73
113
|
|
74
114
|
Filter included partials.
|
75
115
|
|
76
|
-
{% include
|
77
|
-
{% include
|
78
|
-
|
79
|
-
Yes, it can handle a complex combination of features… but can you?
|
116
|
+
{% wrap include greeting.html %} yo, {{ yield }}{% endwrap %} //=> yo, what's up?
|
117
|
+
{% wrap include greeting.html %} yo, {{ yield | upcase }}{% endwrap %} //=> yo, WHAT'S UP?
|
118
|
+
{% wrap include greeting.html | upcase %} Yo, {{ yield }}{% endwrap %} //=> YO, WHAT'S UP?
|
80
119
|
|
81
|
-
{% include (post ? post_sidebar : page_sidebar) | smart_quotes unless site.theme.sidebar == false %}
|
82
120
|
|
83
121
|
### Include partials with an Octopress Ink plugin.
|
84
122
|
|
@@ -86,43 +124,20 @@ It's easy to include a partial from an Ink theme or plugin.
|
|
86
124
|
|
87
125
|
Here's the syntax
|
88
126
|
|
89
|
-
{% include [plugin-slug]:[partial-name] %}
|
127
|
+
{% wrap include [plugin-slug]:[partial-name] %}
|
128
|
+
{{ yield }}
|
129
|
+
{% endwrap %}
|
90
130
|
|
91
131
|
Some examples:
|
92
132
|
|
93
|
-
{% include theme:sidebar.html %} // Include the sidebar from a theme plugin
|
94
|
-
|
95
|
-
|
96
|
-
#### Overriding theme/plugin partials
|
97
|
-
|
98
|
-
Plugins and themes use this tag internally too. For example, the [octopress-feeds plugin](https://github.com/octopress/feeds/blob/master/assets/pages/article-feed.xml#L10) uses the include tag to
|
99
|
-
render partials for the RSS feed.
|
100
|
-
|
101
|
-
{% for post in site.articles %}
|
102
|
-
<entry>
|
103
|
-
{% include feeds:entry.xml %}
|
104
|
-
</entry>
|
105
|
-
{% endfor %}
|
106
|
-
|
107
|
-
|
108
|
-
If you want to make a change to the `entry.xml` partial, you could create your own version at `_plugins/feeds/includes/entry.xml`.
|
109
|
-
Now whenever `{% include feeds:entry.xml %}` is called, the include tag will use *your* local partial instead of the plugin's partial.
|
110
|
-
|
111
|
-
Note: To make overriding partials easier, you can copy all of a plugin's partials to your local override path with the Octopress Ink command:
|
112
|
-
|
113
|
-
octopress ink copy [plugin-slug] [options]
|
114
|
-
|
115
|
-
To copy all includes from the feeds plugin, you'd run:
|
116
|
-
|
117
|
-
octopress ink copy feeds --includes
|
118
|
-
|
119
|
-
This will copy all of the partials from octopress-feeds to `_plugins/feeds/includes/`. Modify any of the partials, and delete those that you want to be read from the plugin.
|
120
|
-
|
121
|
-
To list all partials from a plugin, run:
|
133
|
+
{% wrap include theme:sidebar.html %} // Include the sidebar from a theme plugin
|
134
|
+
<aside>{{ yield }}</aside>
|
135
|
+
{% endwrap %}
|
122
136
|
|
123
|
-
|
137
|
+
{% wrap include twitter:feed.html %} // Include the feed from a twitter plugin
|
138
|
+
<div class="twitter-feed">{{ yield }}</div>
|
139
|
+
{% endwrap %}
|
124
140
|
|
125
|
-
Note: When a plugin is updated, your local partials may be out of date, but will still override the plugin's partials. Be sure to watch changelogs and try to keep your modifications current.
|
126
141
|
|
127
142
|
## Contributing
|
128
143
|
|
data/lib/octopress-wrap-tag.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "octopress-wrap-tag/version"
|
2
|
-
require "octopress-wrap-tag/ink-plugin"
|
3
2
|
|
4
3
|
require "octopress-tag-helpers"
|
5
4
|
require "octopress-include-tag"
|
@@ -11,7 +10,7 @@ require "jekyll"
|
|
11
10
|
#
|
12
11
|
module Octopress
|
13
12
|
module Tags
|
14
|
-
module
|
13
|
+
module Wrap
|
15
14
|
class Tag < Liquid::Block
|
16
15
|
|
17
16
|
def initialize(tag_name, markup, tokens)
|
@@ -46,13 +45,13 @@ module Octopress
|
|
46
45
|
content = Octopress::Tags::Yield::Tag.new('yield', markup, []).render(context)
|
47
46
|
when 'render'
|
48
47
|
begin
|
49
|
-
content = Octopress::Tags::
|
48
|
+
content = Octopress::Tags::Render::Tag.new('render', markup, []).render(context)
|
50
49
|
rescue => error
|
51
50
|
error_msg error
|
52
51
|
end
|
53
52
|
when 'include'
|
54
53
|
begin
|
55
|
-
content = Octopress::Tags::
|
54
|
+
content = Octopress::Tags::Include::Tag.new('include', markup, []).render(context)
|
56
55
|
rescue => error
|
57
56
|
error_msg error
|
58
57
|
end
|
@@ -88,4 +87,15 @@ module Octopress
|
|
88
87
|
end
|
89
88
|
end
|
90
89
|
|
91
|
-
Liquid::Template.register_tag('wrap', Octopress::Tags::
|
90
|
+
Liquid::Template.register_tag('wrap', Octopress::Tags::Wrap::Tag)
|
91
|
+
|
92
|
+
if defined? Octopress::Docs
|
93
|
+
Octopress::Docs.add({
|
94
|
+
name: "Octopress Wrap Tag",
|
95
|
+
gem: "octopress-wrap-tag",
|
96
|
+
version: Octopress::Tags::Wrap::VERSION,
|
97
|
+
description: "Wrap include, render, and yield tags",
|
98
|
+
path: File.expand_path(File.join(File.dirname(__FILE__), "../")),
|
99
|
+
source_url: "https://github.com/octopress/wrap-tag"
|
100
|
+
})
|
101
|
+
end
|
data/octopress-wrap-tag.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'octopress-wrap-tag/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "octopress-wrap-tag"
|
8
|
-
spec.version = Octopress::Tags::
|
8
|
+
spec.version = Octopress::Tags::Wrap::VERSION
|
9
9
|
spec.authors = ["Brandon Mathis"]
|
10
10
|
spec.email = ["brandon@imathis.com"]
|
11
11
|
spec.summary = %q{A Liquid block tag which makes it easy to wrap an include, render or yield tag with html}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octopress-wrap-tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octopress-tag-helpers
|
@@ -158,6 +158,7 @@ executables: []
|
|
158
158
|
extensions: []
|
159
159
|
extra_rdoc_files: []
|
160
160
|
files:
|
161
|
+
- ".clash.yml"
|
161
162
|
- ".gitignore"
|
162
163
|
- ".travis.yml"
|
163
164
|
- CHANGELOG.md
|
@@ -168,10 +169,8 @@ files:
|
|
168
169
|
- assets/docs/changelog.markdown
|
169
170
|
- assets/docs/index.markdown
|
170
171
|
- lib/octopress-wrap-tag.rb
|
171
|
-
- lib/octopress-wrap-tag/ink-plugin.rb
|
172
172
|
- lib/octopress-wrap-tag/version.rb
|
173
173
|
- octopress-wrap-tag.gemspec
|
174
|
-
- test/.clash.yml
|
175
174
|
- test/.gitignore
|
176
175
|
- test/Gemfile
|
177
176
|
- test/_config.yml
|
@@ -214,7 +213,6 @@ specification_version: 4
|
|
214
213
|
summary: A Liquid block tag which makes it easy to wrap an include, render or yield
|
215
214
|
tag with html
|
216
215
|
test_files:
|
217
|
-
- test/.clash.yml
|
218
216
|
- test/.gitignore
|
219
217
|
- test/Gemfile
|
220
218
|
- test/_config.yml
|
@@ -1,11 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'octopress-ink'
|
3
|
-
|
4
|
-
Octopress::Ink.add_plugin({
|
5
|
-
name: 'Wrap Tag',
|
6
|
-
assets_path: File.join(File.expand_path(File.dirname(__FILE__)), '../../assets' ),
|
7
|
-
description: "A Liquid block tag which makes it easy to wrap an include, render or yield tag with html"
|
8
|
-
})
|
9
|
-
rescue LoadError
|
10
|
-
end
|
11
|
-
|