@nakedcreativity/cee-ms-node 0.3.11 → 0.3.12
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 +34 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -132,6 +132,40 @@ function ceems(config) {
|
|
|
132
132
|
}
|
|
133
133
|
})
|
|
134
134
|
|
|
135
|
+
this.engine.registerTag('data', {
|
|
136
|
+
parse: function(tagToken, remainTokens) {
|
|
137
|
+
this.match = tagToken.args.split(' '); // name // path[0] == navigation name
|
|
138
|
+
},
|
|
139
|
+
render: function(scope, hash){
|
|
140
|
+
// var filepath = Liquid.evalValue(this.match[1]+'.liquid', scope);
|
|
141
|
+
|
|
142
|
+
console.log('look for data collection', this.match[0])
|
|
143
|
+
|
|
144
|
+
if(site.collections[this.match[0]]){
|
|
145
|
+
console.log(site.collections[this.match[0]]._id)
|
|
146
|
+
var collection = JSON.parse(fs.readFileSync('./data/'+site.collections[this.match[0]]._id+'.json', 'utf8'));
|
|
147
|
+
|
|
148
|
+
var scopeObj = {}
|
|
149
|
+
scopeObj[this.match[0]] = collection.data
|
|
150
|
+
scope.push(scopeObj)
|
|
151
|
+
|
|
152
|
+
console.log(scope)
|
|
153
|
+
|
|
154
|
+
return engine.handleCache(this.match[1]+'.liquid')
|
|
155
|
+
.then((templates) => {
|
|
156
|
+
return engine.renderer.renderTemplates(templates, scope);
|
|
157
|
+
})
|
|
158
|
+
.then((html) => {
|
|
159
|
+
scope.pop();
|
|
160
|
+
return html;
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
}else {
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
|
|
135
169
|
this.engine.registerTag('blog', {
|
|
136
170
|
parse: function(tagToken, remainTokens) {
|
|
137
171
|
this.match = tagToken.args.split(' ')
|