octopress-ink 1.0.0.alpha.21 → 1.0.0.alpha.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/octopress-ink/assets/asset.rb +1 -1
- data/lib/octopress-ink/helpers/conditional.rb +3 -3
- data/lib/octopress-ink/helpers/var.rb +9 -0
- data/lib/octopress-ink/tags/assign.rb +3 -5
- data/lib/octopress-ink/tags/capture.rb +3 -5
- data/lib/octopress-ink/tags/content_for.rb +3 -5
- data/lib/octopress-ink/tags/footer.rb +1 -0
- data/lib/octopress-ink/tags/head.rb +1 -0
- data/lib/octopress-ink/tags/include.rb +12 -9
- data/lib/octopress-ink/tags/return.rb +17 -0
- data/lib/octopress-ink/tags/scripts.rb +1 -0
- data/lib/octopress-ink/tags/wrap.rb +47 -0
- data/lib/octopress-ink/tags/yield.rb +2 -4
- data/lib/octopress-ink/tags.rb +2 -1
- data/lib/octopress-ink/version.rb +1 -1
- data/lib/octopress-ink.rb +3 -1
- data/test/_config.yml +1 -0
- data/test/_sass_compact.yml +0 -1
- data/test/expected/test_tags/head.html +1 -1
- data/test/expected/test_tags/include.html +24 -1
- data/test/expected/test_tags/wrap.html +18 -0
- data/test/sass_compact/stylesheets/all-e10f647557c9d610df6df40a458bc823.css +0 -4
- data/test/site/test_tags/head.html +1 -1
- data/test/site/test_tags/include.html +24 -1
- data/test/site/test_tags/return.html +23 -0
- data/test/site/test_tags/wrap.html +18 -0
- data/test/source/test_tags/assign.html +1 -1
- data/test/source/test_tags/include.html +26 -1
- data/test/source/test_tags/return.html +30 -0
- data/test/source/test_tags/wrap.html +21 -0
- data/test/test.rb +1 -1
- metadata +13 -26
- data/lib/octopress-ink/tags/wrap_yield.rb +0 -33
- data/test/expected/test_tags/include_if.html +0 -6
- data/test/expected/test_tags/include_plugin.html +0 -1
- data/test/expected/test_tags/include_theme.html +0 -2
- data/test/expected/test_tags/include_theme_override.html +0 -1
- data/test/site/test_tags/include_if.html +0 -6
- data/test/site/test_tags/include_plugin.html +0 -1
- data/test/site/test_tags/include_theme.html +0 -2
- data/test/site/test_tags/include_theme_override.html +0 -1
- data/test/source/test_tags/include_if.html +0 -6
- data/test/source/test_tags/include_plugin.html +0 -3
- data/test/source/test_tags/include_theme.html +0 -4
- data/test/source/test_tags/include_theme_override.html +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddc8138d15559a1928f3bc9d7f4a4d8a6ab95fcd
|
4
|
+
data.tar.gz: 6dc4f36adadf0d70480f395e2d98077c2d025e94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdbb1c6acc6f9188b803e22503f4d37c1e4982f1a0bc7965f9bc317586ed16fe848161532bf830a0fcdab177323efdbcbe8eeddac9a016927fb8118e2c42c774
|
7
|
+
data.tar.gz: 063ac8ad2903c3d679b9710c463fa148cc870825e32abefb4b3ab4fb1e0ebc5ca8bc3f3debc6cf032566bf042aab2e19dc8a86c6d98f0592248a717ba952b4c5
|
@@ -25,7 +25,7 @@ module Octopress
|
|
25
25
|
files << plugin_path unless @plugin.type == 'local_plugin'
|
26
26
|
files = files.flatten.reject { |f| !exists? f }
|
27
27
|
|
28
|
-
|
28
|
+
if files.empty?
|
29
29
|
raise IOError.new "Could not find #{File.basename(@file)} at #{@file}"
|
30
30
|
end
|
31
31
|
@found_file = Pathname.new files[0]
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Octopress
|
2
2
|
module Helpers
|
3
3
|
module Conditional
|
4
|
-
SYNTAX = /(
|
4
|
+
SYNTAX = /(.*)(if|unless)\s*(.+)/
|
5
5
|
|
6
6
|
def self.parse(markup, context)
|
7
7
|
if markup =~ SYNTAX
|
@@ -11,9 +11,9 @@ module Octopress
|
|
11
11
|
when 'unless'
|
12
12
|
tag = Liquid::Unless.new('unless', $3, ["true","{% endunless %}"])
|
13
13
|
end
|
14
|
-
tag.render(context) != ''
|
14
|
+
tag.render(context) != '' ? $1 : false
|
15
15
|
else
|
16
|
-
|
16
|
+
markup
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Octopress
|
2
2
|
module Helpers
|
3
3
|
module Var
|
4
|
+
TERNARY = /(.*?)\(\s*(.+?)\s+\?\s+(.+?)\s+:\s+(.+?)\s*\)(.+)?/
|
4
5
|
|
5
6
|
def self.set_var(var, operator, value, context)
|
6
7
|
case operator
|
@@ -19,6 +20,9 @@ module Octopress
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def self.get_value(vars, context)
|
23
|
+
if vars =~ TERNARY
|
24
|
+
vars = $1 + evaluate_ternary($2, $3, $4, context) + $5
|
25
|
+
end
|
22
26
|
vars = vars.strip.gsub(/ or /, ' || ')
|
23
27
|
vars = vars.split(/ \|\| /).map { |v|
|
24
28
|
Liquid::Variable.new(v.strip).render(context)
|
@@ -26,6 +30,11 @@ module Octopress
|
|
26
30
|
|
27
31
|
vars.empty? ? nil : vars.first
|
28
32
|
end
|
33
|
+
|
34
|
+
def self.evaluate_ternary(expression, if_true, if_false, context)
|
35
|
+
Conditional.parse("if #{expression}", context) ? if_true : if_false
|
36
|
+
end
|
37
|
+
|
29
38
|
end
|
30
39
|
end
|
31
40
|
end
|
@@ -9,12 +9,10 @@ module Octopress
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def render(context)
|
12
|
-
|
13
|
-
|
14
|
-
@markup = $1
|
15
|
-
end
|
12
|
+
markup = Helpers::Conditional.parse(@markup, context)
|
13
|
+
return unless markup
|
16
14
|
|
17
|
-
if
|
15
|
+
if markup =~ SYNTAX
|
18
16
|
var = $1
|
19
17
|
operator = $2
|
20
18
|
value = $3
|
@@ -9,12 +9,10 @@ module Octopress
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def render(context)
|
12
|
-
|
13
|
-
|
14
|
-
@markup = $1
|
15
|
-
end
|
12
|
+
markup = Helpers::Conditional.parse(@markup, context)
|
13
|
+
return unless markup
|
16
14
|
|
17
|
-
if
|
15
|
+
if markup =~ SYNTAX
|
18
16
|
var = $1
|
19
17
|
operator = $2
|
20
18
|
value = super.lstrip
|
@@ -10,12 +10,10 @@ module Octopress
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def render(context)
|
13
|
-
|
14
|
-
|
15
|
-
@markup = $1
|
16
|
-
end
|
13
|
+
markup = Helpers::Conditional.parse(@markup, context)
|
14
|
+
return unless markup
|
17
15
|
|
18
|
-
@block_name ||= Helpers::ContentFor.get_block_name(@tag_name,
|
16
|
+
@block_name ||= Helpers::ContentFor.get_block_name(@tag_name, markup)
|
19
17
|
Helpers::ContentFor.append_to_block(context, @block_name, super)
|
20
18
|
''
|
21
19
|
end
|
@@ -5,22 +5,25 @@ module Octopress
|
|
5
5
|
|
6
6
|
def initialize(tag_name, markup, tokens)
|
7
7
|
super
|
8
|
-
@markup = markup
|
8
|
+
@og_markup = @markup = markup
|
9
9
|
end
|
10
10
|
|
11
11
|
def render(context)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
12
|
+
markup = Helpers::Conditional.parse(@markup, context)
|
13
|
+
return unless markup
|
14
|
+
markup = Helpers::Path.parse(markup, context)
|
16
15
|
|
17
|
-
include_tag = Jekyll::Tags::IncludeTag.new('include',
|
16
|
+
include_tag = Jekyll::Tags::IncludeTag.new('include', markup, [])
|
18
17
|
|
19
18
|
# If markup references a plugin e.g. plugin-name:include-file.html
|
20
|
-
if
|
19
|
+
if markup.strip =~ PLUGIN_SYNTAX
|
21
20
|
plugin = $1
|
22
21
|
path = $2
|
23
|
-
|
22
|
+
begin
|
23
|
+
content = Plugins.include(plugin, path, context.registers[:site]).read
|
24
|
+
rescue => error
|
25
|
+
raise IOError.new "Include failed: {% #{@tag_name} #{@og_markup}%}. The plugin '#{plugin}' does not have an include named '#{path}'."
|
26
|
+
end
|
24
27
|
partial = Liquid::Template.parse(content)
|
25
28
|
context.stack {
|
26
29
|
context['include'] = include_tag.parse_params(context)
|
@@ -28,7 +31,7 @@ module Octopress
|
|
28
31
|
}.strip
|
29
32
|
# Otherwise, use Jekyll's default include tag
|
30
33
|
else
|
31
|
-
include_tag.render(context)
|
34
|
+
include_tag.render(context).strip
|
32
35
|
end
|
33
36
|
end
|
34
37
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Tags
|
3
|
+
class ReturnTag < Liquid::Tag
|
4
|
+
def initialize(tag_name, markup, tokens)
|
5
|
+
@markup = markup.strip
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
def render(context)
|
10
|
+
markup = Helpers::Conditional.parse(@markup, context)
|
11
|
+
return unless markup
|
12
|
+
|
13
|
+
Helpers::Var.get_value(@markup, context)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Inspired by jekyll-contentblocks https://github.com/rustygeldmacher/jekyll-contentblocks
|
2
|
+
#
|
3
|
+
module Octopress
|
4
|
+
module Tags
|
5
|
+
class WrapTag < Liquid::Block
|
6
|
+
HAS_YIELD = /(.*?)({=\s*yield\s*})(.*)/im
|
7
|
+
def initialize(tag_name, markup, tokens)
|
8
|
+
super
|
9
|
+
@og_markup = @markup = markup
|
10
|
+
@tag_name = tag_name
|
11
|
+
end
|
12
|
+
|
13
|
+
def render(context)
|
14
|
+
markup = Helpers::Conditional.parse(@markup, context)
|
15
|
+
return unless markup
|
16
|
+
|
17
|
+
case @tag_name
|
18
|
+
when 'wrap_yield'
|
19
|
+
content = content_for(markup, context)
|
20
|
+
when 'wrap'
|
21
|
+
begin
|
22
|
+
content = include_tag = Octopress::Tags::IncludeTag.new('include', markup, []).render(context)
|
23
|
+
rescue => error
|
24
|
+
error.message
|
25
|
+
message = "Wrap failed: {% #{@tag_name} #{@og_markup}%}."
|
26
|
+
message << $1 if error.message =~ /%}\.(.+)/
|
27
|
+
raise IOError.new message
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
wrap = super.strip
|
32
|
+
|
33
|
+
if wrap =~ HAS_YIELD && content != ''
|
34
|
+
$1 + content + $3
|
35
|
+
else
|
36
|
+
''
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def content_for(markup, context)
|
41
|
+
@block_name = Helpers::ContentFor.get_block_name(@tag_name, markup)
|
42
|
+
Helpers::ContentFor.render(context, @block_name).strip
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -9,10 +9,8 @@ module Octopress
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def render(context)
|
12
|
-
|
13
|
-
|
14
|
-
@markup = $1
|
15
|
-
end
|
12
|
+
markup = Helpers::Conditional.parse(@markup, context)
|
13
|
+
return unless markup
|
16
14
|
|
17
15
|
content = Helpers::ContentFor.render(context, @block_name)
|
18
16
|
if @block_name == 'head'
|
data/lib/octopress-ink/tags.rb
CHANGED
@@ -2,6 +2,7 @@ module Octopress
|
|
2
2
|
module Tags
|
3
3
|
autoload :IncludeTag, 'octopress-ink/tags/include'
|
4
4
|
autoload :AssignTag, 'octopress-ink/tags/assign'
|
5
|
+
autoload :ReturnTag, 'octopress-ink/tags/return'
|
5
6
|
autoload :CaptureTag, 'octopress-ink/tags/capture'
|
6
7
|
autoload :JavascriptTag, 'octopress-ink/tags/javascript'
|
7
8
|
autoload :StylesheetTag, 'octopress-ink/tags/stylesheet'
|
@@ -10,7 +11,7 @@ module Octopress
|
|
10
11
|
autoload :FooterBlock, 'octopress-ink/tags/footer'
|
11
12
|
autoload :YieldTag, 'octopress-ink/tags/yield'
|
12
13
|
autoload :ScriptsBlock, 'octopress-ink/tags/scripts'
|
13
|
-
autoload :
|
14
|
+
autoload :WrapTag, 'octopress-ink/tags/wrap'
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
data/lib/octopress-ink.rb
CHANGED
@@ -27,6 +27,7 @@ end
|
|
27
27
|
Liquid::Template.register_tag('include', Octopress::Tags::IncludeTag)
|
28
28
|
Liquid::Template.register_tag('assign', Octopress::Tags::AssignTag)
|
29
29
|
Liquid::Template.register_tag('capture', Octopress::Tags::CaptureTag)
|
30
|
+
Liquid::Template.register_tag('return', Octopress::Tags::ReturnTag)
|
30
31
|
Liquid::Template.register_tag('octopress_js', Octopress::Tags::JavascriptTag)
|
31
32
|
Liquid::Template.register_tag('octopress_css', Octopress::Tags::StylesheetTag)
|
32
33
|
Liquid::Template.register_tag('content_for', Octopress::Tags::ContentForBlock)
|
@@ -34,7 +35,8 @@ Liquid::Template.register_tag('head', Octopress::Tags::HeadBlock)
|
|
34
35
|
Liquid::Template.register_tag('footer', Octopress::Tags::FooterBlock)
|
35
36
|
Liquid::Template.register_tag('scripts', Octopress::Tags::ScriptsBlock)
|
36
37
|
Liquid::Template.register_tag('yield', Octopress::Tags::YieldTag)
|
37
|
-
Liquid::Template.register_tag('wrap_yield', Octopress::Tags::
|
38
|
+
Liquid::Template.register_tag('wrap_yield', Octopress::Tags::WrapTag)
|
39
|
+
Liquid::Template.register_tag('wrap', Octopress::Tags::WrapTag)
|
38
40
|
|
39
41
|
Octopress.register_plugin(Octopress::StylesheetsPlugin, 'user stylesheets', 'local_plugin')
|
40
42
|
|
data/test/_config.yml
CHANGED
data/test/_sass_compact.yml
CHANGED
@@ -1,2 +1,25 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
|
3
|
+
## Testing a simple include
|
4
|
+
Testing Include → Testing Include
|
5
|
+
|
6
|
+
## Local var passing
|
7
|
+
Testing Include var_test → Testing Include var_test
|
8
|
+
|
9
|
+
## Conditional Include
|
10
|
+
'' → ''
|
11
|
+
'' → ''
|
12
|
+
'' → ''
|
13
|
+
Testing Include → Testing Include
|
14
|
+
Testing Include → Testing Include
|
15
|
+
Testing Include var_test → Testing Include var_test
|
16
|
+
|
17
|
+
## Plugin wraps
|
18
|
+
include from plugin → include from plugin
|
19
|
+
Yo Dawg, I heard you like includes. → Yo Dawg, I heard you like includes.
|
20
|
+
'' → ''
|
21
|
+
Yo Dawg, I heard you like includes. → Yo Dawg, I heard you like includes.
|
22
|
+
|
23
|
+
## Theme Include override
|
24
|
+
include from theme override → include from theme override
|
2
25
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
## Testing a simple wrap
|
4
|
+
[- Testing Include -] → [- Testing Include -]
|
5
|
+
|
6
|
+
## Local var passing
|
7
|
+
[- Testing Include var_test -] → [- Testing Include var_test -]
|
8
|
+
|
9
|
+
## Conditional wrap
|
10
|
+
'' → ''
|
11
|
+
'' → ''
|
12
|
+
[- Testing Include -] → [- Testing Include -]
|
13
|
+
[- Testing Include -] → [- Testing Include -]
|
14
|
+
|
15
|
+
## Plugin wraps
|
16
|
+
[- include from plugin -] → [- include from plugin -]
|
17
|
+
[- Yo Dawg, I heard you like includes. -] → [- Yo Dawg, I heard you like includes. -]
|
18
|
+
|
@@ -3,7 +3,6 @@ body { margin: 2px; padding: 2px; }
|
|
3
3
|
|
4
4
|
.main { color: #444; }
|
5
5
|
|
6
|
-
/* line 2 */
|
7
6
|
body { background: black; }
|
8
7
|
|
9
8
|
/* Plugin: awesome-sauce */
|
@@ -12,11 +11,8 @@ body { background: black; }
|
|
12
11
|
/* Plugin: user stylesheets */
|
13
12
|
.css-plugin { background: #fed; }
|
14
13
|
|
15
|
-
/* line 1, /Users/imathis/workspace/octodev/ink/test/source/stylesheets/_foo.scss */
|
16
14
|
body { display: table; }
|
17
15
|
|
18
|
-
/* line 4, /Users/imathis/workspace/octodev/ink/test/source/stylesheets/site.sass */
|
19
16
|
body { background: #aaa111; }
|
20
17
|
|
21
|
-
/* line 6, /Users/imathis/workspace/octodev/ink/test/source/stylesheets/site.sass */
|
22
18
|
div { display: table; }
|
@@ -1,2 +1,25 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
|
3
|
+
## Testing a simple include
|
4
|
+
Testing Include → Testing Include
|
5
|
+
|
6
|
+
## Local var passing
|
7
|
+
Testing Include var_test → Testing Include var_test
|
8
|
+
|
9
|
+
## Conditional Include
|
10
|
+
'' → ''
|
11
|
+
'' → ''
|
12
|
+
'' → ''
|
13
|
+
Testing Include → Testing Include
|
14
|
+
Testing Include → Testing Include
|
15
|
+
Testing Include var_test → Testing Include var_test
|
16
|
+
|
17
|
+
## Plugin wraps
|
18
|
+
include from plugin → include from plugin
|
19
|
+
Yo Dawg, I heard you like includes. → Yo Dawg, I heard you like includes.
|
20
|
+
'' → ''
|
21
|
+
Yo Dawg, I heard you like includes. → Yo Dawg, I heard you like includes.
|
22
|
+
|
23
|
+
## Theme Include override
|
24
|
+
include from theme override → include from theme override
|
2
25
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
## Simple return
|
4
|
+
bar → bar
|
5
|
+
|
6
|
+
## Conditional return
|
7
|
+
bar → bar
|
8
|
+
'' → ''
|
9
|
+
|
10
|
+
## Ternary return
|
11
|
+
nope → nope
|
12
|
+
|
13
|
+
## Cascading return
|
14
|
+
nope → nope
|
15
|
+
bar → bar
|
16
|
+
|
17
|
+
## Test local variables
|
18
|
+
yep → yep
|
19
|
+
|
20
|
+
## Returns with filters
|
21
|
+
2013-07-21T18:59:00-05:00 → 2013-07-21T18:59:00-05:00
|
22
|
+
2013-07-21T18:59:00-05:00 → 2013-07-21T18:59:00-05:00
|
23
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
## Testing a simple wrap
|
4
|
+
[- Testing Include -] → [- Testing Include -]
|
5
|
+
|
6
|
+
## Local var passing
|
7
|
+
[- Testing Include var_test -] → [- Testing Include var_test -]
|
8
|
+
|
9
|
+
## Conditional wrap
|
10
|
+
'' → ''
|
11
|
+
'' → ''
|
12
|
+
[- Testing Include -] → [- Testing Include -]
|
13
|
+
[- Testing Include -] → [- Testing Include -]
|
14
|
+
|
15
|
+
## Plugin wraps
|
16
|
+
[- include from plugin -] → [- include from plugin -]
|
17
|
+
[- Yo Dawg, I heard you like includes. -] → [- Yo Dawg, I heard you like includes. -]
|
18
|
+
|
@@ -20,6 +20,6 @@ foo → {% assign var7 = baz || 'foo' %}{{ var7 }}
|
|
20
20
|
yepyep → {% assign var1 += 'yep' %}{{ var1 }}
|
21
21
|
|
22
22
|
## Complex assignment
|
23
|
-
awesome → {% assign var9 = 'awesome' %}{{ var9 }}
|
23
|
+
awesome → {% assign var9 = (page.layout == 'nil' ? 'awesome' : 'lame' ) %}{{ var9 }}
|
24
24
|
AWESOME → {% assign var10 = var9 | upcase %}{{ var10 }}
|
25
25
|
|
@@ -1,3 +1,28 @@
|
|
1
1
|
---
|
2
|
+
layout: nil
|
2
3
|
---
|
3
|
-
{%
|
4
|
+
{% assign some_bool = true %}
|
5
|
+
|
6
|
+
## Testing a simple include
|
7
|
+
Testing Include → {% include foo.html %}
|
8
|
+
|
9
|
+
## Local var passing
|
10
|
+
Testing Include var_test → {% include foo.html some_var="var_test" %}
|
11
|
+
|
12
|
+
## Conditional Include
|
13
|
+
'' → '{% include foo.html unless true %}'
|
14
|
+
'' → '{% include foo.html unless some_bool %}'
|
15
|
+
'' → '{% include foo.html unless site.name == 'Your New Jekyll Site' %}'
|
16
|
+
Testing Include → {% include foo.html if true %}
|
17
|
+
Testing Include → {% include foo.html if site.name == 'Your New Jekyll Site' %}
|
18
|
+
Testing Include var_test → {% include foo.html some_var="var_test" if some_bool %}
|
19
|
+
|
20
|
+
## Plugin wraps
|
21
|
+
include from plugin → {% include awesome-sauce:some-include.html %}
|
22
|
+
Yo Dawg, I heard you like includes. → {% include theme:greet.html greeting="Yo Dawg" %}
|
23
|
+
'' → '{% include theme:greet.html greeting="Yo Dawg" unless some_bool %}'
|
24
|
+
Yo Dawg, I heard you like includes. → {% include theme:greet.html greeting="Yo Dawg" if some_bool %}
|
25
|
+
|
26
|
+
## Theme Include override
|
27
|
+
include from theme override → {% include theme:bar.html %}
|
28
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
layout: nil
|
3
|
+
date: 2013-07-21 18:59
|
4
|
+
people:
|
5
|
+
- { name: Bill }
|
6
|
+
- { name: Bob }
|
7
|
+
---
|
8
|
+
{% assign foo = 'bar' %}
|
9
|
+
|
10
|
+
## Simple return
|
11
|
+
bar → {% return foo %}
|
12
|
+
|
13
|
+
## Conditional return
|
14
|
+
bar → {% return foo if foo %}
|
15
|
+
'' → '{% return foo unless foo == 'bar' %}'
|
16
|
+
|
17
|
+
## Ternary return
|
18
|
+
nope → {% return (foo == 'baz' ? foo : 'nope') %}
|
19
|
+
|
20
|
+
## Cascading return
|
21
|
+
nope → {% return bingo || fez || 'nope' %}
|
22
|
+
bar → {% return bingo || fez || foo %}
|
23
|
+
|
24
|
+
## Test local variables
|
25
|
+
yep → {% for person in page.people %}{% return 'yep' if person.name == 'Bill' %}{% endfor %}
|
26
|
+
|
27
|
+
## Returns with filters
|
28
|
+
2013-07-21T18:59:00-05:00 → {% return post.date or page.date | datetime | date_to_xmlschema %}
|
29
|
+
2013-07-21T18:59:00-05:00 → {% return (post ? post.date : page.date) | datetime | date_to_xmlschema %}
|
30
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
layout: nil
|
3
|
+
---
|
4
|
+
{% assign some_bool = true %}
|
5
|
+
|
6
|
+
## Testing a simple wrap
|
7
|
+
[- Testing Include -] → {% wrap foo.html %}[- {=yield} -]{% endwrap %}
|
8
|
+
|
9
|
+
## Local var passing
|
10
|
+
[- Testing Include var_test -] → {% wrap foo.html some_var="var_test" %}[- {=yield} -]{% endwrap %}
|
11
|
+
|
12
|
+
## Conditional wrap
|
13
|
+
'' → '{% wrap foo.html unless true %}[- {=yield} -]{% endwrap %}'
|
14
|
+
'' → '{% wrap foo.html unless some_bool %}[- {=yield} -]{% endwrap %}'
|
15
|
+
[- Testing Include -] → {% wrap foo.html if true %}[- {=yield} -]{% endwrap %}
|
16
|
+
[- Testing Include -] → {% wrap foo.html if some_bool %}[- {=yield} -]{% endwrap %}
|
17
|
+
|
18
|
+
## Plugin wraps
|
19
|
+
[- include from plugin -] → {% wrap awesome-sauce:some-include.html %}[- {=yield} -]{% endwrap %}
|
20
|
+
[- Yo Dawg, I heard you like includes. -] → {% wrap theme:greet.html greeting="Yo Dawg" %}[- {=yield} -]{% endwrap %}
|
21
|
+
|
data/test/test.rb
CHANGED
@@ -39,7 +39,7 @@ end
|
|
39
39
|
build
|
40
40
|
|
41
41
|
def test_tags(dir)
|
42
|
-
tags = %w{content_for footer head include
|
42
|
+
tags = %w{content_for footer head include scripts assign capture wrap}
|
43
43
|
tags.each { |file| test("test_tags/#{file}.html", dir) }
|
44
44
|
end
|
45
45
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octopress-ink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.alpha.
|
4
|
+
version: 1.0.0.alpha.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
@@ -124,9 +124,10 @@ files:
|
|
124
124
|
- lib/octopress-ink/tags/head.rb
|
125
125
|
- lib/octopress-ink/tags/include.rb
|
126
126
|
- lib/octopress-ink/tags/javascript.rb
|
127
|
+
- lib/octopress-ink/tags/return.rb
|
127
128
|
- lib/octopress-ink/tags/scripts.rb
|
128
129
|
- lib/octopress-ink/tags/stylesheet.rb
|
129
|
-
- lib/octopress-ink/tags/
|
130
|
+
- lib/octopress-ink/tags/wrap.rb
|
130
131
|
- lib/octopress-ink/tags/yield.rb
|
131
132
|
- lib/octopress-ink/version.rb
|
132
133
|
- octopress-ink.gemspec
|
@@ -160,11 +161,8 @@ files:
|
|
160
161
|
- test/expected/test_tags/footer.html
|
161
162
|
- test/expected/test_tags/head.html
|
162
163
|
- test/expected/test_tags/include.html
|
163
|
-
- test/expected/test_tags/include_if.html
|
164
|
-
- test/expected/test_tags/include_plugin.html
|
165
|
-
- test/expected/test_tags/include_theme.html
|
166
|
-
- test/expected/test_tags/include_theme_override.html
|
167
164
|
- test/expected/test_tags/scripts.html
|
165
|
+
- test/expected/test_tags/wrap.html
|
168
166
|
- test/sass_compact/stylesheets/all-e10f647557c9d610df6df40a458bc823.css
|
169
167
|
- test/sass_compact/stylesheets/print-0dc274efb4e3fba0ae71bd22eef6fb38.css
|
170
168
|
- test/sass_expanded/stylesheets/all-e10f647557c9d610df6df40a458bc823.css
|
@@ -187,11 +185,9 @@ files:
|
|
187
185
|
- test/site/test_tags/footer.html
|
188
186
|
- test/site/test_tags/head.html
|
189
187
|
- test/site/test_tags/include.html
|
190
|
-
- test/site/test_tags/
|
191
|
-
- test/site/test_tags/include_plugin.html
|
192
|
-
- test/site/test_tags/include_theme.html
|
193
|
-
- test/site/test_tags/include_theme_override.html
|
188
|
+
- test/site/test_tags/return.html
|
194
189
|
- test/site/test_tags/scripts.html
|
190
|
+
- test/site/test_tags/wrap.html
|
195
191
|
- test/source/.gitignore
|
196
192
|
- test/source/_custom/awesome-sauce/config.yml
|
197
193
|
- test/source/_custom/theme/config.yml
|
@@ -242,11 +238,9 @@ files:
|
|
242
238
|
- test/source/test_tags/footer.html
|
243
239
|
- test/source/test_tags/head.html
|
244
240
|
- test/source/test_tags/include.html
|
245
|
-
- test/source/test_tags/
|
246
|
-
- test/source/test_tags/include_plugin.html
|
247
|
-
- test/source/test_tags/include_theme.html
|
248
|
-
- test/source/test_tags/include_theme_override.html
|
241
|
+
- test/source/test_tags/return.html
|
249
242
|
- test/source/test_tags/scripts.html
|
243
|
+
- test/source/test_tags/wrap.html
|
250
244
|
- test/test.rb
|
251
245
|
homepage: https://github.com/octopress/ink
|
252
246
|
licenses:
|
@@ -303,11 +297,8 @@ test_files:
|
|
303
297
|
- test/expected/test_tags/footer.html
|
304
298
|
- test/expected/test_tags/head.html
|
305
299
|
- test/expected/test_tags/include.html
|
306
|
-
- test/expected/test_tags/include_if.html
|
307
|
-
- test/expected/test_tags/include_plugin.html
|
308
|
-
- test/expected/test_tags/include_theme.html
|
309
|
-
- test/expected/test_tags/include_theme_override.html
|
310
300
|
- test/expected/test_tags/scripts.html
|
301
|
+
- test/expected/test_tags/wrap.html
|
311
302
|
- test/sass_compact/stylesheets/all-e10f647557c9d610df6df40a458bc823.css
|
312
303
|
- test/sass_compact/stylesheets/print-0dc274efb4e3fba0ae71bd22eef6fb38.css
|
313
304
|
- test/sass_expanded/stylesheets/all-e10f647557c9d610df6df40a458bc823.css
|
@@ -330,11 +321,9 @@ test_files:
|
|
330
321
|
- test/site/test_tags/footer.html
|
331
322
|
- test/site/test_tags/head.html
|
332
323
|
- test/site/test_tags/include.html
|
333
|
-
- test/site/test_tags/
|
334
|
-
- test/site/test_tags/include_plugin.html
|
335
|
-
- test/site/test_tags/include_theme.html
|
336
|
-
- test/site/test_tags/include_theme_override.html
|
324
|
+
- test/site/test_tags/return.html
|
337
325
|
- test/site/test_tags/scripts.html
|
326
|
+
- test/site/test_tags/wrap.html
|
338
327
|
- test/source/.gitignore
|
339
328
|
- test/source/_custom/awesome-sauce/config.yml
|
340
329
|
- test/source/_custom/theme/config.yml
|
@@ -385,9 +374,7 @@ test_files:
|
|
385
374
|
- test/source/test_tags/footer.html
|
386
375
|
- test/source/test_tags/head.html
|
387
376
|
- test/source/test_tags/include.html
|
388
|
-
- test/source/test_tags/
|
389
|
-
- test/source/test_tags/include_plugin.html
|
390
|
-
- test/source/test_tags/include_theme.html
|
391
|
-
- test/source/test_tags/include_theme_override.html
|
377
|
+
- test/source/test_tags/return.html
|
392
378
|
- test/source/test_tags/scripts.html
|
379
|
+
- test/source/test_tags/wrap.html
|
393
380
|
- test/test.rb
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# Inspired by jekyll-contentblocks https://github.com/rustygeldmacher/jekyll-contentblocks
|
2
|
-
#
|
3
|
-
module Octopress
|
4
|
-
module Tags
|
5
|
-
class WrapYieldBlock < Liquid::Block
|
6
|
-
HAS_YIELD = /(.*?)({=\s*yield\s*})(.*)/im
|
7
|
-
def initialize(tag_name, markup, tokens)
|
8
|
-
super
|
9
|
-
@markup = markup
|
10
|
-
@tag_name = tag_name
|
11
|
-
end
|
12
|
-
|
13
|
-
def render(context)
|
14
|
-
if @markup =~ Helpers::Conditional::SYNTAX
|
15
|
-
return unless Helpers::Conditional.parse(@markup, context)
|
16
|
-
@markup = $1
|
17
|
-
end
|
18
|
-
|
19
|
-
@block_name = Helpers::ContentFor.get_block_name(@tag_name, @markup)
|
20
|
-
|
21
|
-
wrap = super.strip
|
22
|
-
content = Helpers::ContentFor.render(context, @block_name).strip
|
23
|
-
|
24
|
-
if wrap =~ HAS_YIELD && content != ''
|
25
|
-
$1 + content + $3
|
26
|
-
else
|
27
|
-
''
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
include from plugin
|
@@ -1 +0,0 @@
|
|
1
|
-
include from theme override
|
@@ -1 +0,0 @@
|
|
1
|
-
include from plugin
|
@@ -1 +0,0 @@
|
|
1
|
-
include from theme override
|
@@ -1,6 +0,0 @@
|
|
1
|
-
---
|
2
|
-
---
|
3
|
-
{% include foo.html some_var="var_test" if site.name == 'Your New Jekyll Site' %}
|
4
|
-
{% include site.include_test some_var="var_test" if site.name != 'Your New Jekyll Site' %}
|
5
|
-
{% include site.include_test some_var="var_test" unless site.name == 'Your New Jekyll Site' %}
|
6
|
-
{% include site.include_test some_var="var_test" unless site.name == 'Your Stupid Website' %}
|