jekyll-liquid-plus 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +345 -0
- data/Rakefile +1 -0
- data/jekyll-liquid-plus.gemspec +24 -0
- data/lib/jekyll-liquid-plus.rb +20 -0
- data/lib/jekyll-liquid-plus/helpers/conditional.rb +43 -0
- data/lib/jekyll-liquid-plus/helpers/include.rb +46 -0
- data/lib/jekyll-liquid-plus/helpers/path.rb +73 -0
- data/lib/jekyll-liquid-plus/helpers/var.rb +47 -0
- data/lib/jekyll-liquid-plus/tags/assign.rb +19 -0
- data/lib/jekyll-liquid-plus/tags/capture.rb +34 -0
- data/lib/jekyll-liquid-plus/tags/include.rb +16 -0
- data/lib/jekyll-liquid-plus/tags/render.rb +133 -0
- data/lib/jekyll-liquid-plus/tags/return.rb +20 -0
- data/lib/jekyll-liquid-plus/tags/wrap.rb +36 -0
- data/lib/jekyll-liquid-plus/version.rb +3 -0
- data/test/_config.yml +4 -0
- data/test/source/.gitignore +1 -0
- data/test/source/_includes/file.html +1 -0
- data/test/source/_includes/file2.html +1 -0
- data/test/source/_layouts/default.html +11 -0
- data/test/source/_plugins/liquid-plus.rb +2 -0
- data/test/source/assign.html +30 -0
- data/test/source/capture.html +29 -0
- data/test/source/f/file.html +1 -0
- data/test/source/f/file2.html +1 -0
- data/test/source/f/file3.md +6 -0
- data/test/source/include.html +31 -0
- data/test/source/render.html +36 -0
- data/test/source/return.html +24 -0
- data/test/source/wrap.html +29 -0
- data/test/test.rb +44 -0
- metadata +135 -0
data/test/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
_site
|
@@ -0,0 +1 @@
|
|
1
|
+
file.html
|
@@ -0,0 +1 @@
|
|
1
|
+
file2.html {% if include.var %}and {{ include.var }} {% endif %}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
layout: nil
|
3
|
+
---
|
4
|
+
## Simple assign
|
5
|
+
yep → {% assign var1 = 'yep' %}{{ var1 }}
|
6
|
+
yep → {% assign var2 = 'yep' %}{{ var2 }}
|
7
|
+
|
8
|
+
## Conditional assign
|
9
|
+
'' → '{% assign var3 = 'yep' unless true %}{{ var3 }}'
|
10
|
+
nope → {% assign var4 = 'nope' if true %}{{ var4 }}
|
11
|
+
nope → {% assign var4 ||= 'yep' %}{{ var4 }}
|
12
|
+
yep → {% assign varz ||= 'yep' %}{{ varz }}
|
13
|
+
|
14
|
+
## Ternary assign
|
15
|
+
nope → {% assign var5 = (false ? 'yep' : var4) %}{{ var5 }}
|
16
|
+
|
17
|
+
## Cascading assign
|
18
|
+
nope → {% assign var6 = baz || var4 %}{{ var6 }}
|
19
|
+
foo → {% assign var7 = baz || 'foo' %}{{ var7 }}
|
20
|
+
'' → '{% assign var8 = baz || foo || nil %}{{ var8 }}'
|
21
|
+
|
22
|
+
## Additive assign
|
23
|
+
yepyep → {% assign var1 += 'yep' %}{{ var1 }}
|
24
|
+
|
25
|
+
## Complex assignment
|
26
|
+
awesome → {% assign var9 = (page.layout == 'nil' ? 'awesome' : 'lame' ) %}{{ var9 }}
|
27
|
+
|
28
|
+
## Filter values
|
29
|
+
AWESOME → {% assign var10 = var9 | upcase %}{{ var10 }}
|
30
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
---
|
2
|
+
layout: nil
|
3
|
+
---
|
4
|
+
{% assign some_bool = false %}
|
5
|
+
## Simple capture
|
6
|
+
hi → {% capture var1 %}hi{% endcapture %}{{ var1 }}
|
7
|
+
|
8
|
+
## Conditional capture
|
9
|
+
'' → '{% capture var2 unless true %}hi{% endcapture %}{{ var2 }}'
|
10
|
+
hi → {% capture var3 if true %}hi{% endcapture %}{{ var3 }}
|
11
|
+
'' → '{% capture var4 if some_bool %}hi{% endcapture %}{{ var4 }}'
|
12
|
+
hi → {% capture var3 ||= %}nooooo{% endcapture %}{{ var3 }}
|
13
|
+
hi → {% capture varz ||= %}hi{% endcapture %}{{ varz }}
|
14
|
+
|
15
|
+
## Additive capture
|
16
|
+
hihi → {% capture var3 += if true %}hi{% endcapture %}{{ var3 }}
|
17
|
+
|
18
|
+
## Ternary capture
|
19
|
+
hi → {% capture (var3 != 'hihi' ? var3 : var5) %}hi{% endcapture %}{{ var5}}
|
20
|
+
|
21
|
+
## Complex capture
|
22
|
+
hi → {% capture (2 + 2 == 4 ? var6 : var7) if var3 == 'hihi' %}hi{% endcapture %}{{ var6}}
|
23
|
+
hi → {% capture var8 if false or page.layout %}hi{% endcapture %}{{ var8 }}
|
24
|
+
um, hi → {% capture var9 if false or page.layout %}
|
25
|
+
{% assign var10 = 'hi' %}
|
26
|
+
um, {{ var10 }}
|
27
|
+
{% endcapture %}{{ var9 }}
|
28
|
+
|
29
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
file.html
|
@@ -0,0 +1 @@
|
|
1
|
+
file2.html {% if render.var %}and {{ render.var }} {% endif %}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
---
|
2
|
+
layout: nil
|
3
|
+
---
|
4
|
+
{% assign file = 'file.html' %}
|
5
|
+
{% assign some_bool = true %}
|
6
|
+
{% assign test_var = 'variable' %}
|
7
|
+
|
8
|
+
## Simple include
|
9
|
+
file.html → {% include file.html %}
|
10
|
+
|
11
|
+
## File name stored in variable name
|
12
|
+
file.html → {% include file %}
|
13
|
+
|
14
|
+
## Post conditional include
|
15
|
+
'' → '{% include file.html unless true %}'
|
16
|
+
file.html → {% include file.html if some_bool %}
|
17
|
+
|
18
|
+
## Ternary include
|
19
|
+
file2.html → {% include (false ? file.html : file2.html) %}
|
20
|
+
file.html → {% include (some_bool ? file.html : file2.html) %}
|
21
|
+
|
22
|
+
## Cascading include
|
23
|
+
file.html → {% include not_there.html || file.html %}
|
24
|
+
'' → '{% include not_there.html || none %}'
|
25
|
+
From include.html: File 'not_there.html' not found in '_includes/' directory → {% include nothing || not_there.html %}
|
26
|
+
|
27
|
+
## Complex includes
|
28
|
+
file2.html and variable → {% include (some_bool ? not_here : file.html) || file2.html var='variable' %}
|
29
|
+
'' → '{% include (some_bool ? not_here : file.html) || file2.html var='variable' unless true %}'
|
30
|
+
file2.html and variable → {% include (some_bool ? not_here : file.html) || file2.html var='variable' if some_bool %}
|
31
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
layout: nil
|
3
|
+
---
|
4
|
+
{% assign file = 'f/file.html' %}
|
5
|
+
{% assign some_bool = true %}
|
6
|
+
{% assign test_var = 'variable' %}
|
7
|
+
|
8
|
+
## Simple include
|
9
|
+
file.html → {% render f/file.html %}
|
10
|
+
|
11
|
+
## File name stored in variable name
|
12
|
+
file.html → {% render file %}
|
13
|
+
|
14
|
+
## Post conditional include
|
15
|
+
'' → '{% render f/file.html unless true %}'
|
16
|
+
file.html → {% render f/file.html if some_bool %}
|
17
|
+
|
18
|
+
## Ternary include
|
19
|
+
file2.html → {% render (false ? f/file.html : f/file2.html) %}
|
20
|
+
file.html → {% render (some_bool ? f/file.html : f/file2.html) %}
|
21
|
+
|
22
|
+
## Cascading include
|
23
|
+
file.html → {% render not_there.html || f/file.html %}
|
24
|
+
'' → '{% render not_there.html or none %}'
|
25
|
+
From render.html: File 'not_there.html' not found → {% render nothing || not_there.html %}
|
26
|
+
|
27
|
+
## Complex includes
|
28
|
+
file2.html and variable → {% render (some_bool ? not_here : f/file.html) || f/file2.html var='variable' %}
|
29
|
+
'' → '{% render (some_bool ? not_here : f/file.html) || f/file2.html var='variable' unless true %}'
|
30
|
+
file2.html and variable → {% render (some_bool ? not_here : f/file.html) || f/file2.html var='variable' if some_bool %}
|
31
|
+
|
32
|
+
## Render with local vars
|
33
|
+
<p><strong>howdybar</strong></p> → {% render f/file3.md foo='bar' %}
|
34
|
+
|
35
|
+
## Render raw
|
36
|
+
{% raw %}**{{ page.test_var }}{{ render.foo }}**{% endraw %} → {% render raw f/file3.md %}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
layout: nil
|
3
|
+
date: 2013-07-21 18:59
|
4
|
+
---
|
5
|
+
{% assign foo = 'bar' %}
|
6
|
+
|
7
|
+
## Simple return
|
8
|
+
bar → {% return foo %}
|
9
|
+
|
10
|
+
## Conditional return
|
11
|
+
bar → {% return foo if foo %}
|
12
|
+
'' → '{% return foo unless foo == 'bar' %}'
|
13
|
+
|
14
|
+
## Ternary return
|
15
|
+
nope → {% return (foo == 'baz' ? foo : 'nope') %}
|
16
|
+
|
17
|
+
## Cascading return
|
18
|
+
nope → {% return bingo || fez || 'nope' %}
|
19
|
+
bar → {% return bingo || fez || foo %}
|
20
|
+
|
21
|
+
## Returns with filters
|
22
|
+
2013-07-21T18:59:00-05:00 → {% return post.date or page.date | datetime | date_to_xmlschema %}
|
23
|
+
2013-07-21T18:59:00-05:00 → {% return (post ? post.date : page.date) | datetime | date_to_xmlschema %}
|
24
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
---
|
2
|
+
layout: nil
|
3
|
+
---
|
4
|
+
{% assign some_bool = true %}
|
5
|
+
|
6
|
+
## Testing a simple wrap
|
7
|
+
[- file2.html -] → {% wrap_include file2.html %}[- {=yield} -]{% endwrap_include %}
|
8
|
+
|
9
|
+
## Local var passing
|
10
|
+
[- file2.html and working? -] → {% wrap_include file2.html var='working?' %}[- {=yield} -]{% endwrap_include %}
|
11
|
+
|
12
|
+
## Conditional wrap
|
13
|
+
'' → '{% wrap_include file2.html unless true %}[- {=yield} -]{% endwrap_include %}'
|
14
|
+
[- file2.html -] → {% wrap_include file2.html if true %}[- {=yield} -]{% endwrap_include %}
|
15
|
+
|
16
|
+
## Ternary wrap
|
17
|
+
[- file2.html -] → {% wrap (false ? f/file.html : f/file2.html) %}[- {=yield} -]{% endwrap %}
|
18
|
+
[- file.html -] → {% wrap (some_bool ? f/file.html : f/file2.html) %}[- {=yield} -]{% endwrap %}
|
19
|
+
|
20
|
+
## Cascading wrap
|
21
|
+
[- file.html -] → {% wrap not_there.html || f/file.html %}[- {=yield} -]{% endwrap %}
|
22
|
+
'' → '{% wrap not_there.html || none %}[- {=yield} -]{% endwrap %}'
|
23
|
+
[- From wrap.html: File 'not_there.html' not found in '_includes/' directory -] → {% wrap_include nothing || not_there.html %}[- {=yield} -]{% endwrap_include %}
|
24
|
+
|
25
|
+
## Complex wraps
|
26
|
+
[- file2.html and variable -] → {% wrap (some_bool ? not_here : f/file.html) || f/file2.html var='variable' %}[- {=yield} -]{% endwrap %}
|
27
|
+
'' → '{% wrap (some_bool ? not_here : f/file.html) || f/file2.html var='variable' unless true %}[- {=yield} -]{% endwrap %}'
|
28
|
+
[- file2.html and variable -] → {% wrap (some_bool ? not_here : f/file.html) || f/file2.html var='variable' if some_bool %}[- {=yield} -]{% endwrap %}
|
29
|
+
|
data/test/test.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'pathname'
|
3
|
+
require 'colorator'
|
4
|
+
|
5
|
+
def test(path)
|
6
|
+
path = Pathname.new path + '.html'
|
7
|
+
failure = []
|
8
|
+
start = 0
|
9
|
+
|
10
|
+
f = File.new("source/#{path}")
|
11
|
+
# Get the starting line (after the YAML FM) for source map
|
12
|
+
f.each do |line|
|
13
|
+
if line =~ /---/ and f.lineno > 1
|
14
|
+
break start = f.lineno + 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Dir.chdir('_site') do
|
19
|
+
File.readlines(path).each_with_index do |line, i|
|
20
|
+
if line =~ /(.+?)→(.+)/
|
21
|
+
if $1.strip != $2.strip
|
22
|
+
failure << " - line #{i+start}: #{$1}!=#{$2}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
if failure.size > 0
|
28
|
+
puts "failed".red + ": #{path}"
|
29
|
+
puts failure.join "\n"
|
30
|
+
else
|
31
|
+
puts "passed".green + ": #{path}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
`bundle exec jekyll build --trace`
|
36
|
+
|
37
|
+
# Test include
|
38
|
+
|
39
|
+
test 'include'
|
40
|
+
test 'render'
|
41
|
+
test 'wrap'
|
42
|
+
test 'assign'
|
43
|
+
test 'capture'
|
44
|
+
test 'return'
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-liquid-plus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brandon Mathis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.1.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: liquid
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.5.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.5.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Super powered Liquid tags for smarter Jekyll templating.
|
70
|
+
email:
|
71
|
+
- brandon@imathis.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- jekyll-liquid-plus.gemspec
|
82
|
+
- lib/jekyll-liquid-plus.rb
|
83
|
+
- lib/jekyll-liquid-plus/helpers/conditional.rb
|
84
|
+
- lib/jekyll-liquid-plus/helpers/include.rb
|
85
|
+
- lib/jekyll-liquid-plus/helpers/path.rb
|
86
|
+
- lib/jekyll-liquid-plus/helpers/var.rb
|
87
|
+
- lib/jekyll-liquid-plus/tags/assign.rb
|
88
|
+
- lib/jekyll-liquid-plus/tags/capture.rb
|
89
|
+
- lib/jekyll-liquid-plus/tags/include.rb
|
90
|
+
- lib/jekyll-liquid-plus/tags/render.rb
|
91
|
+
- lib/jekyll-liquid-plus/tags/return.rb
|
92
|
+
- lib/jekyll-liquid-plus/tags/wrap.rb
|
93
|
+
- lib/jekyll-liquid-plus/version.rb
|
94
|
+
- test/_config.yml
|
95
|
+
- test/source/.gitignore
|
96
|
+
- test/source/_includes/file.html
|
97
|
+
- test/source/_includes/file2.html
|
98
|
+
- test/source/_layouts/default.html
|
99
|
+
- test/source/_plugins/liquid-plus.rb
|
100
|
+
- test/source/assign.html
|
101
|
+
- test/source/capture.html
|
102
|
+
- test/source/f/file.html
|
103
|
+
- test/source/f/file2.html
|
104
|
+
- test/source/f/file3.md
|
105
|
+
- test/source/include.html
|
106
|
+
- test/source/render.html
|
107
|
+
- test/source/return.html
|
108
|
+
- test/source/wrap.html
|
109
|
+
- test/test.rb
|
110
|
+
homepage: https://github.com/imathis/jekyll-liquid-plus
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.0.7
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: ! 'Do things easier with better versions of common liquid tags: include,
|
134
|
+
capture, assign, and introducing: render, wrap, wrap_include, and more.'
|
135
|
+
test_files: []
|