1 | var ejs = require('ejs');
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | module.exports = function processor(content, attrs, scope) {
|
14 | if (!content) {
|
15 | return content;
|
16 | }
|
17 | var render = ejs.compile(content);
|
18 | var data;
|
19 | if (attrs.data) {
|
20 |
|
21 | data = scope.execImport(attrs.data);
|
22 | if (typeof data === 'string') {
|
23 | data = new Function(
|
24 | 'return (' + data + ');'
|
25 | )();
|
26 | }
|
27 | }
|
28 | else {
|
29 | data = null;
|
30 | }
|
31 | if (/^(off|false|no)$/.test(attrs.rework)) {
|
32 | return render(data);
|
33 | } else {
|
34 | return scope.compile(render(data));
|
35 | }
|
36 | }; |
\ | No newline at end of file |