@nakedcreativity/cee-ms-node 0.3.23 → 0.3.25
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.
- package/index.js +55 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -160,19 +160,23 @@ function ceems(config) {
|
|
|
160
160
|
render: function(scope, hash){
|
|
161
161
|
// var filepath = Liquid.evalValue(this.match[1]+'.liquid', scope);
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if(site.collections[
|
|
166
|
-
//console.log(site.collections[
|
|
167
|
-
var collection = JSON.parse(fs.readFileSync('./data/'+site.collections[
|
|
163
|
+
var collectionName = Liquid.evalValue(this.match[0], scope)
|
|
164
|
+
|
|
165
|
+
if(site.collections[collectionName]){
|
|
166
|
+
//console.log(site.collections[collection]._id)
|
|
167
|
+
var collection = JSON.parse(fs.readFileSync('./data/'+site.collections[collectionName]._id+'.json', 'utf8'));
|
|
168
168
|
|
|
169
169
|
var scopeObj = {}
|
|
170
|
-
scopeObj[
|
|
170
|
+
scopeObj['collection'] = collection
|
|
171
171
|
scope.push(scopeObj)
|
|
172
172
|
|
|
173
173
|
//console.log(scope)
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
var template = Liquid.lexical.parseLiteral(this.match[1])
|
|
175
|
+
if (!template) {
|
|
176
|
+
template = this.match[1]
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return engine.handleCache(template+'.liquid')
|
|
176
180
|
.then((templates) => {
|
|
177
181
|
return engine.renderer.renderTemplates(templates, scope);
|
|
178
182
|
})
|
|
@@ -186,6 +190,39 @@ function ceems(config) {
|
|
|
186
190
|
}
|
|
187
191
|
}
|
|
188
192
|
})
|
|
193
|
+
|
|
194
|
+
this.engine.registerTag('external', {
|
|
195
|
+
parse: function (tagToken, remainTokens) {
|
|
196
|
+
this.match = tagToken.args.split(' '); // name // path[0] == navigation name
|
|
197
|
+
},
|
|
198
|
+
render: function (scope, hash) {
|
|
199
|
+
|
|
200
|
+
var filepath = Liquid.lexical.parseLiteral(this.match[0])
|
|
201
|
+
var jsonData = JSON.parse(fs.readFileSync(filepath, 'utf8'))
|
|
202
|
+
|
|
203
|
+
var scopeObj = {}
|
|
204
|
+
scopeObj['external'] = jsonData
|
|
205
|
+
scope.push(scopeObj)
|
|
206
|
+
|
|
207
|
+
//console.log(scope)
|
|
208
|
+
var template = Liquid.lexical.parseLiteral(this.match[1])
|
|
209
|
+
if (!template) {
|
|
210
|
+
template = this.match[1]
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return engine.handleCache(template + '.liquid')
|
|
214
|
+
.then((templates) => {
|
|
215
|
+
return engine.renderer.renderTemplates(templates, scope);
|
|
216
|
+
})
|
|
217
|
+
.then((html) => {
|
|
218
|
+
scope.pop();
|
|
219
|
+
return html;
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
}
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
|
|
189
226
|
this.engine.registerFilter('active', (path, match, cssClass) => {
|
|
190
227
|
|
|
191
228
|
var regex = new RegExp("^"+match)
|
|
@@ -212,6 +249,11 @@ function ceems(config) {
|
|
|
212
249
|
render: function(scope, hash) {
|
|
213
250
|
var image = Liquid.evalExp(this.args[0], scope);
|
|
214
251
|
//console.log(image)
|
|
252
|
+
|
|
253
|
+
if(!image){
|
|
254
|
+
return Promise.resolve('')
|
|
255
|
+
}
|
|
256
|
+
|
|
215
257
|
if(this.args[1] && image.variants && image.variants[this.args[1]]){
|
|
216
258
|
var src = image.variants[this.args[1]]
|
|
217
259
|
}else {
|
|
@@ -228,6 +270,11 @@ function ceems(config) {
|
|
|
228
270
|
},
|
|
229
271
|
render: function(scope, hash) {
|
|
230
272
|
var image = Liquid.evalExp(this.args[0], scope);
|
|
273
|
+
|
|
274
|
+
if(!image){
|
|
275
|
+
return Promise.resolve('')
|
|
276
|
+
}
|
|
277
|
+
|
|
231
278
|
//console.log(image)
|
|
232
279
|
if(this.args[1] && image.variants && image.variants[this.args[1]]){
|
|
233
280
|
var src = image.variants[this.args[1]]
|