Authored by 沈志敏

采用lib中的hbs模版引擎

... ... @@ -20,7 +20,6 @@ const favicon = require('serve-favicon');
const yohoLib = require('yoho-node-lib');
const session = require('express-session');
const memcached = require('connect-memcached');
const hbs = require('express-handlebars');
const pkg = require('./package.json');
const devtools = require('./doraemon/middleware/devtools');
... ... @@ -45,13 +44,12 @@ if (app.locals.devEnv) {
app.use(devtools());
}
app.set('view engine', '.hbs');
app.set('views', './doraemon/views');
app.engine('.hbs', hbs({
app.use(global.yoho.hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: './doraemon/views',
partialsDir: './doraemon/views/partial',
layoutsDir: path.join(__dirname, 'doraemon/views'),
partialsDir: path.join(__dirname, 'doraemon/views/partial'),
views: path.join(__dirname, 'doraemon/views'),
helpers: global.yoho.helpers
}));
... ...
... ... @@ -13,7 +13,7 @@ module.exports = {
index(req, res) {
let channel = req.path.split('/')[1] || req.yoho.channel;
res.render('index', {
res.render('cindex', {
module: 'channel',
page: 'home',
channel: channel
... ...
/**
* 主页
* @author: Bi Kai<kai.bi@yoho.cn>
* @date: 2016/05/09
*/
'use strict';
/**
* 频道选择页
*/
const component = {
index: (req, res) => {
res.render('index', {
module: 'example',
page: 'home'
});
}
};
module.exports = component;
... ... @@ -6,7 +6,6 @@
const express = require('express');
const path = require('path');
const hbs = require('express-handlebars');
const app = express();
... ... @@ -18,12 +17,12 @@ app.on('mount', function(parent) {
Object.assign(app.locals, parent.locals);
});
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
app.use(global.yoho.hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
partialsDir: [`${doraemon}/partial`],
views: path.join(__dirname, 'views/action'),
helpers: global.yoho.helpers
}));
... ...
... ... @@ -6,7 +6,6 @@
const express = require('express');
const path = require('path');
const hbs = require('express-handlebars');
const app = express();
... ... @@ -18,13 +17,12 @@ app.on('mount', function(parent) {
Object.assign(app.locals, parent.locals);
});
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
app.use(global.yoho.hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
partialsDir: [`${doraemon}/partial`],
views: path.join(__dirname, 'views/action'),
helpers: global.yoho.helpers
}));
... ...
... ... @@ -11,7 +11,7 @@ const example = {
* 示例页面
*/
index: (req, res) => {
res.render('index', {
res.render('eindex', {
module: 'example',
page: 'home'
});
... ...
... ... @@ -6,7 +6,6 @@
const express = require('express');
const path = require('path');
const hbs = require('express-handlebars');
const app = express();
... ... @@ -18,12 +17,12 @@ app.on('mount', function(parent) {
Object.assign(app.locals, parent.locals);
});
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
app.use(global.yoho.hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
partialsDir: [`${doraemon}/partial`],
views: path.join(__dirname, 'views/action'),
helpers: global.yoho.helpers
}));
... ...
... ... @@ -12,16 +12,7 @@ const helpers = global.yoho.helpers;
*/
const component = {
index: (req, res) => {
const uid = req.user.uid;
if (!uid && req.xhr) {
return res.json({
code: 400,
message: '抱歉,您暂未登录!'
});
}
res.render('index', {
res.render('mindex', {
module: 'me',
page: 'index'
});
... ...
... ... @@ -6,7 +6,6 @@
const express = require('express');
const path = require('path');
const hbs = require('express-handlebars');
const app = express();
... ... @@ -18,12 +17,12 @@ app.on('mount', function(parent) {
Object.assign(app.locals, parent.locals);
});
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
app.use(global.yoho.hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
views: path.join(__dirname, 'views/action'),
helpers: global.yoho.helpers
}));
... ...
... ... @@ -22,7 +22,7 @@ const component = {
goodsId = req.params[1],
cnAlphabet = req.params[2];
res.render('detail', {
res.render('pdetail', {
module: 'product',
page: 'detail',
pid: pid,
... ...
... ... @@ -6,7 +6,6 @@
const express = require('express');
const path = require('path');
const hbs = require('express-handlebars');
const app = express();
... ... @@ -18,12 +17,12 @@ app.on('mount', function(parent) {
Object.assign(app.locals, parent.locals);
});
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
app.use(global.yoho.hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
partialsDir: [`${doraemon}/partial`],
views: path.join(__dirname, 'views/action'),
helpers: global.yoho.helpers
}));
... ...
... ... @@ -25,7 +25,6 @@
"connect-multiparty": "^2.0.0",
"cookie-parser": "^1.4.3",
"express": "^4.14.0",
"express-handlebars": "^3.0.0",
"express-session": "^1.14.1",
"influxdb-winston": "^1.0.1",
"lodash": "^4.15.0",
... ...