Authored by ccbikai

模板中注入版本

Showing 1 changed file with 3 additions and 1 deletions
@@ -9,7 +9,8 @@ let express = require('express'), @@ -9,7 +9,8 @@ let express = require('express'),
9 path = require('path'), 9 path = require('path'),
10 bodyParser = require('body-parser'), 10 bodyParser = require('body-parser'),
11 cookieParser = require('cookie-parser'), 11 cookieParser = require('cookie-parser'),
12 - favicon = require('serve-favicon'); 12 + favicon = require('serve-favicon'),
  13 + pkg = require('./package.json');
13 14
14 require('express-handlebars'); 15 require('express-handlebars');
15 16
@@ -18,6 +19,7 @@ let app = express(); @@ -18,6 +19,7 @@ let app = express();
18 19
19 // 向模板注入变量 20 // 向模板注入变量
20 app.locals.devEnv = app.get('env') === 'development'; 21 app.locals.devEnv = app.get('env') === 'development';
  22 +app.locals.version = pkg.version;
21 23
22 app.set('view engine', '.hbs'); 24 app.set('view engine', '.hbs');
23 25