-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
31 lines (25 loc) · 787 Bytes
/
main.js
File metadata and controls
31 lines (25 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Alpine.js
*
* A Template Engine for NodeJS.
*
* See LICENSE for details on copyright and project licensing.
*/
const fs = require('fs');
var alpineExpress = function(templatePath, options, callback){
return "<h1>Hello World!</h1>";
}
var render = function(templatePath, data, callback) {
//TODO: Make sure this throws propper errors
fs.readFile(templatePath, function(err, fileData){
var template = fileData.toString();
for(var key in data){
var value = data[key];
template = template.replace('{{' + key + '}}', value);
}
callback(template);
//TODO: implement array syntax
});
}
//Public API
exports.__express = alpineExpress; //For use with the alpine web framework
exports.render = render;