@nakedcreativity/cee-ms-node 0.3.24 → 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.
Files changed (2) hide show
  1. package/index.js +22 -8
  2. 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
- //console.log('look for data collection', this.match[0])
164
-
165
- if(site.collections[this.match[0]]){
166
- //console.log(site.collections[this.match[0]]._id)
167
- var collection = JSON.parse(fs.readFileSync('./data/'+site.collections[this.match[0]]._id+'.json', 'utf8'));
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[this.match[0]] = collection.data
170
+ scopeObj['collection'] = collection
171
171
  scope.push(scopeObj)
172
172
 
173
173
  //console.log(scope)
174
-
175
- return engine.handleCache(this.match[1]+'.liquid')
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
  })
@@ -245,6 +249,11 @@ function ceems(config) {
245
249
  render: function(scope, hash) {
246
250
  var image = Liquid.evalExp(this.args[0], scope);
247
251
  //console.log(image)
252
+
253
+ if(!image){
254
+ return Promise.resolve('')
255
+ }
256
+
248
257
  if(this.args[1] && image.variants && image.variants[this.args[1]]){
249
258
  var src = image.variants[this.args[1]]
250
259
  }else {
@@ -261,6 +270,11 @@ function ceems(config) {
261
270
  },
262
271
  render: function(scope, hash) {
263
272
  var image = Liquid.evalExp(this.args[0], scope);
273
+
274
+ if(!image){
275
+ return Promise.resolve('')
276
+ }
277
+
264
278
  //console.log(image)
265
279
  if(this.args[1] && image.variants && image.variants[this.args[1]]){
266
280
  var src = image.variants[this.args[1]]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nakedcreativity/cee-ms-node",
3
- "version": "0.3.24",
3
+ "version": "0.3.25",
4
4
  "description": "Cee.ms for Node.js",
5
5
  "main": "index.js",
6
6
  "scripts": {