1 | import fs from 'fs-extra' |
||
2 | import path from 'path' |
||
3 | |||
4 | import { |
||
5 | Manager, |
||
6 | coreUtils, |
||
7 | config, |
||
8 | Handlebars |
||
9 | } from '../../cli' |
||
10 | |||
11 | var route = function(req, res){ |
||
12 | var resHtml = '' |
||
13 | |||
14 | var page = path.join(__dirname + '/../views/list-structure.html') |
||
0 ignored issues
–
show
Compatibility
introduced
by
![]() |
|||
15 | if (coreUtils.file.exist(page)) { |
||
16 | resHtml = fs.readFileSync(page, 'utf8') |
||
17 | } |
||
18 | |||
19 | var structure = Manager.instance.getStructureAndTemplates().structure |
||
20 | structure = JSON.stringify(structure).replace(new RegExp(config.root, 'g'), '') |
||
21 | var template = Handlebars.compile(resHtml, {noEscape: true}) |
||
22 | var tmp = template({ |
||
23 | config: JSON.stringify(config), |
||
24 | structure: structure |
||
25 | }) |
||
26 | return res.send(tmp) |
||
27 | } |
||
28 | |||
29 | export default route |
||
30 |