jekyll-template 0.18.0 → 0.19.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/.gitignore +1 -0
- data/lib/jekyll/template.rb +42 -6
- data/lib/jekyll/template/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3cfd7d22291e09bd926714707e2f3e999d1dc7d
|
4
|
+
data.tar.gz: 4d246888810dd10beee9a6557a50fcf134186a0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7f35139c84975ef8335d7b98240bb3aaceba52f78c7f2b79d79cc26f07b9bd523f535305e657ba7c14405317dd9cd535acfe0bbb981ac7f7e03994f2c43af17
|
7
|
+
data.tar.gz: 67c40f775d2ac0cd641f63d8ed604388b4acdfba817508d775e4fe7960d51f5c1b7d14576602ca6081fe174e5c4ed6efe74c2b239513811265cbc9ba87163314
|
data/.gitignore
CHANGED
data/lib/jekyll/template.rb
CHANGED
@@ -24,6 +24,7 @@ module Jekyll
|
|
24
24
|
@template_name = $1.freeze
|
25
25
|
@attributes = {}
|
26
26
|
@sanitize = false
|
27
|
+
@id = rand(36**8).to_s(36)
|
27
28
|
|
28
29
|
# Parse parameters
|
29
30
|
# Source: https://gist.github.com/jgatjens/8925165
|
@@ -35,6 +36,10 @@ module Jekyll
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
39
|
+
def id
|
40
|
+
@id
|
41
|
+
end
|
42
|
+
|
38
43
|
# blank?
|
39
44
|
# Description: Override's Liquid's default blank checker. This allows
|
40
45
|
# for templates to be used without passing inner content.
|
@@ -59,7 +64,6 @@ module Jekyll
|
|
59
64
|
})
|
60
65
|
|
61
66
|
add_template_to_dependency(@template_name, context)
|
62
|
-
|
63
67
|
template = load_cached_template(@template_name, context)
|
64
68
|
|
65
69
|
# Define the default template attributes
|
@@ -71,7 +75,7 @@ module Jekyll
|
|
71
75
|
|
72
76
|
# Parse and extend template's front-matter with content front-matter
|
73
77
|
update_attributes(get_front_matter(content))
|
74
|
-
|
78
|
+
|
75
79
|
# Setting template attributes from @attributes
|
76
80
|
# This allows for @attributes to be used within the template as
|
77
81
|
# {{ template.atttribute_name }}
|
@@ -89,7 +93,11 @@ module Jekyll
|
|
89
93
|
|
90
94
|
context["template"]["content"] = sanitize(strip_front_matter(content))
|
91
95
|
|
92
|
-
|
96
|
+
store_template_data(context)
|
97
|
+
content = compressor.compress(template.render(context))
|
98
|
+
reset_template_data(context)
|
99
|
+
|
100
|
+
content
|
93
101
|
end
|
94
102
|
|
95
103
|
# update_attributes(data)
|
@@ -101,6 +109,34 @@ module Jekyll
|
|
101
109
|
end
|
102
110
|
end
|
103
111
|
|
112
|
+
# store_template_data(context)
|
113
|
+
# Description: Works with reset_template_data. This is a work-around
|
114
|
+
# to ensure data stays in scope and isn't leaked from child->parent
|
115
|
+
# template.
|
116
|
+
def store_template_data(context)
|
117
|
+
context.registers[:template_data_store] ||= {}
|
118
|
+
store = context.registers[:template_data_store]
|
119
|
+
unless store.key?(@id)
|
120
|
+
store[@id] = context["template"]
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# reset_template_data(context)
|
125
|
+
# Description: Works with store_template_data. This is a work-around
|
126
|
+
# to ensure data stays in scope and isn't leaked from child->parent
|
127
|
+
# template.
|
128
|
+
def reset_template_data(context)
|
129
|
+
context.registers[:template_data_store] ||= {}
|
130
|
+
store = context.registers[:template_data_store]
|
131
|
+
if store.keys.size
|
132
|
+
if store.keys[0] == @id
|
133
|
+
store = {}
|
134
|
+
else
|
135
|
+
context["template"] = store[store.keys[0]]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
104
140
|
# add_template_to_dependency(path, context)
|
105
141
|
# source: https://github.com/jekyll/jekyll/blob/e509cf2139d1a7ee11090b09721344608ecf48f6/lib/jekyll/tags/include.rb
|
106
142
|
def add_template_to_dependency(path, context)
|
@@ -156,11 +192,11 @@ module Jekyll
|
|
156
192
|
|
157
193
|
template_obj = Hash.new
|
158
194
|
data = get_front_matter(template_content)
|
159
|
-
|
195
|
+
markup = strip_front_matter(template_content)
|
160
196
|
|
161
197
|
if template_content
|
162
|
-
template_obj["data"] = data
|
163
|
-
template_obj["template"] = file.parse(
|
198
|
+
template_obj["data"] = data
|
199
|
+
template_obj["template"] = file.parse(markup)
|
164
200
|
template_obj
|
165
201
|
else
|
166
202
|
raise Liquid::SyntaxError, "Could not find #{file_path} in your templates"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-template
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ItsJonQ
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|