We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 59befa6 commit b85ad46Copy full SHA for b85ad46
1 file changed
doc/day1_express.md
@@ -275,6 +275,38 @@ https://github.com/expressjs/session
275
276
以及如何用生成器指定模板
277
278
+####jade node模板引擎
279
+
280
+此引擎构建在node之上,需要经过node编译成html代码,例如:
281
282
+```
283
+var app = express();
284
285
+app.set('views', path.join(__dirname, 'views'));
286
+app.set('view engine', 'jade');
287
288
+开启express服务,指定模板路径为views,模板引擎为jade,当客户端访问指定路由时,express便会去给对应的jade文件配置参数,并编译此jade模板:
289
290
291
+router.get('/', function(req, res) {
292
+ res.render('index', { title: 'Express' });
293
+});
294
295
296
+index jade模板:
297
298
299
+extends layout
300
301
+block content
302
+ h1= title
303
+ p Welcome to #{title}
304
305
+最终在客户端输出:
306
307
+
308
309
310
### 理解public目录
311
312
- 常规做法
0 commit comments