-
Notifications
You must be signed in to change notification settings - Fork 30
/
index.js
48 lines (43 loc) · 1.23 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
var _ = require("lodash");
var fs = require("fs");
var path = require("path");
var WEBSITE_TPL = _.template(fs.readFileSync(path.resolve(__dirname, "./assets/website.html")));
var EBOOK_TPL = _.template(fs.readFileSync(path.resolve(__dirname, "./assets/ebook.html")));
module.exports = {
website: {
assets: "./assets",
js: [
"ace/ace.js",
"ace/theme-tomorrow.js",
"ace/mode-javascript.js",
"exercises.js"
],
css: [
"exercises.css"
]
},
ebook: {
assets: "./assets",
css: [
"ebook.css"
]
},
blocks: {
exercise: {
parse: false,
blocks: ["initial", "solution", "validation", "context"],
process: function(blk) {
var codes = {};
_.each(blk.blocks, function(_blk) {
codes[_blk.name] = _blk.body.trim();
});
// Select appropriate template
var tpl = (this.generator === 'website' ? WEBSITE_TPL : EBOOK_TPL);
return tpl({
message: blk.body,
codes: codes
});
}
}
}
};