@nakedcreativity/cee-ms-node 0.3.18 → 0.3.20

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 +31 -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
  })
@@ -174,7 +186,18 @@ function ceems(config) {
174
186
  }
175
187
  }
176
188
  })
189
+ this.engine.registerFilter('active', (path, match, cssClass) => {
190
+
191
+ var regex = new RegExp("^"+match)
192
+
193
+ if(regex.test(path)){
194
+ return cssClass
195
+ }else {
196
+ return ''
197
+ }
177
198
 
199
+ })
200
+
178
201
  this.engine.registerTag('breadcrumb', {
179
202
  parse: function(tagToken, remainTokens) {
180
203
  this.template = tagToken.args
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nakedcreativity/cee-ms-node",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
4
4
  "description": "Cee.ms for Node.js",
5
5
  "main": "index.js",
6
6
  "scripts": {