@nakedcreativity/cee-ms-node 0.3.19 → 0.3.21

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 +53 -8
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -105,25 +105,37 @@ function ceems(config) {
105
105
  },
106
106
  render: function(scope, hash){
107
107
  // var filepath = Liquid.evalValue(this.match[1]+'.liquid', scope);
108
- var page = scope.scopes[0]
109
108
 
110
- console.log('look for page with path', this.match[0])
109
+ var path = Liquid.evalValue(this.match[0], scope)
110
+ if(!path){
111
+ path = Liquid.lexical.parseLiteral(this.match[0])
112
+ }
113
+ if(!path){
114
+ path = this.match[0]
115
+ }
116
+
111
117
 
112
- if(site.pages[this.match[0]]){
113
- var page = site.pages[this.match[0]]
114
- console.log(page)
118
+
119
+ if(site.pages[path]){
120
+ var page = site.pages[path]
121
+
115
122
  if(page.redirect){
116
123
  res.redirect(parseInt(page.redirect.type), page.redirect.to)
117
124
  }
118
125
 
119
126
  var page = JSON.parse(fs.readFileSync('./pages/'+page._id+'.json', 'utf8'));
120
- page.fullpath = site.pages[this.match[0]].url
127
+ page.fullpath = site.pages[path].url
121
128
  page.path = page.fullpath.split('/')
122
129
 
123
- console.log(page)
130
+
124
131
  scope.push(page)
125
132
 
126
- return engine.handleCache(this.match[1]+'.liquid')
133
+ var template = Liquid.lexical.parseLiteral(this.match[1])
134
+ if(!template){
135
+ template = this.match[1]
136
+ }
137
+
138
+ return engine.handleCache(template+'.liquid')
127
139
  .then((templates) => {
128
140
  return engine.renderer.renderTemplates(templates, scope);
129
141
  })
@@ -185,6 +197,39 @@ function ceems(config) {
185
197
  }
186
198
 
187
199
  })
200
+
201
+ this.engine.registerTag('image', {
202
+ parse: function(tagToken, remainTokens) {
203
+ this.args = tagToken.args.split(' ');
204
+ },
205
+ render: function(scope, hash) {
206
+ var image = Liquid.evalExp(this.args[0], scope);
207
+ console.log(image)
208
+ if(this.args[1] && image.variants && image.variants[this.args[1]]){
209
+ var src = image.variants[this.args[1]]
210
+ }else {
211
+ var src = image.src
212
+ }
213
+ var alt = image.alt || ''
214
+ return Promise.resolve('<img src="'+src+'" alt="'+alt+'"/>');
215
+ }
216
+ });
217
+
218
+ this.engine.registerTag('imageurl', {
219
+ parse: function(tagToken, remainTokens) {
220
+ this.args = tagToken.args.split(' ');
221
+ },
222
+ render: function(scope, hash) {
223
+ var image = Liquid.evalExp(this.args[0], scope);
224
+ console.log(image)
225
+ if(this.args[1] && image.variants && image.variants[this.args[1]]){
226
+ var src = image.variants[this.args[1]]
227
+ }else {
228
+ var src = image.src
229
+ }
230
+ return Promise.resolve(src);
231
+ }
232
+ });
188
233
 
189
234
  this.engine.registerTag('breadcrumb', {
190
235
  parse: function(tagToken, remainTokens) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nakedcreativity/cee-ms-node",
3
- "version": "0.3.19",
3
+ "version": "0.3.21",
4
4
  "description": "Cee.ms for Node.js",
5
5
  "main": "index.js",
6
6
  "scripts": {