-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
50 lines (37 loc) · 1.09 KB
/
index.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const
Crather = require('./src/Crather'),
ScriptFunction = require('./src/definitions/ScriptFunction')
;
/**
* Express render function initializer
*/
function express() {
let
crather = new Crather()
;
/**
* Express render function for crather
*
* @param {string} filePath The path to the file you want to render
* @param {Object} options An object of data and options
* @param {function(err: Error, result: string)} callback The callback for when the file is rendered
*/
return function (filePath, options, callback) {
crather.setOptions({
data : options,
templates : options.settings.templates || './templates',
scripts : options.settings.scripts || './scripts'
});
crather.parse(
filePath,
function (err, result) {
callback(err, err ? '' : result.getRendered());
}
);
}.bind(this);
}
// add the express function onto Crather
Crather.express = express;
// add ScriptFunction onto Crather
Crather.script = ScriptFunction;
module.exports = Crather;