Showing
2 changed files
with
47 additions
and
0 deletions
apps/home/index.js
0 → 100644
1 | +/** | ||
2 | + * sub app home | ||
3 | + * @author: shenzm<zhimin.shen@yoho.cn> | ||
4 | + * @date: 2016/07/18 | ||
5 | + */ | ||
6 | + | ||
7 | +var express = require('express'), | ||
8 | + path = require('path'), | ||
9 | + hbs = require('express-handlebars'); | ||
10 | + | ||
11 | +var app = express(); | ||
12 | + | ||
13 | +// set view engin | ||
14 | +var doraemon = path.join(__dirname, '../../doraemon/views'); //parent view root | ||
15 | + | ||
16 | +app.on('mount', function(parent) { | ||
17 | + delete parent.locals.settings; // 不继承父 App 的设置 | ||
18 | + Object.assign(app.locals, parent.locals); | ||
19 | +}); | ||
20 | + | ||
21 | +app.set('views', path.join(__dirname, 'views/action')); | ||
22 | +app.engine('.hbs', hbs({ | ||
23 | + extname: '.hbs', | ||
24 | + defaultLayout: 'layout', | ||
25 | + layoutsDir: doraemon, | ||
26 | + partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`], | ||
27 | + helpers: global.yoho.helpers | ||
28 | +})); | ||
29 | + | ||
30 | +// router | ||
31 | +app.use(require('./router')); | ||
32 | + | ||
33 | +module.exports = app; |
apps/home/router.js
0 → 100644
-
Please register or login to post a comment