jekyll-template 0.18.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6975e356063a9820af8618e472c8124c2c3b0c22
4
- data.tar.gz: 31d6b3136a508fc8d535d97ad0028b997ed26236
3
+ metadata.gz: e3cfd7d22291e09bd926714707e2f3e999d1dc7d
4
+ data.tar.gz: 4d246888810dd10beee9a6557a50fcf134186a0a
5
5
  SHA512:
6
- metadata.gz: 46ab2cacbc17854beb7494015fdd2303b0eb3437a77898fcac3fe2a650fbb56802473690dc83ced68f9256e1cb25c60ba8b1f73e142f1e86a1a32b648ede59b0
7
- data.tar.gz: f1ec53fdb9155e13b335b2316f266c45cbad20426cf6d50aadff692ed4b2f8e88ecdd1a9429f3bcc26a500ba17da715e0679ec21206b262cd9588f877f3dbd8a
6
+ metadata.gz: a7f35139c84975ef8335d7b98240bb3aaceba52f78c7f2b79d79cc26f07b9bd523f535305e657ba7c14405317dd9cd535acfe0bbb981ac7f7e03994f2c43af17
7
+ data.tar.gz: 67c40f775d2ac0cd641f63d8ed604388b4acdfba817508d775e4fe7960d51f5c1b7d14576602ca6081fe174e5c4ed6efe74c2b239513811265cbc9ba87163314
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .DS_Store
1
2
  /.bundle/
2
3
  /.yardoc
3
4
  /Gemfile.lock
@@ -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
- compressor.compress(template.render(context))
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
- content = strip_front_matter(template_content)
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(content)
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"
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Template
3
- VERSION = "0.18.0"
3
+ VERSION = "0.19.0"
4
4
  end
5
5
  end
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.18.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-02 00:00:00.000000000 Z
11
+ date: 2017-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll