2.7 KiB
2.7 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
5895f700f9fc0f352b528e63 | Set up a Template Engine | 2 | 设置模板引擎 |
Description
"pug": "^0.1.0"
现在告诉Node / Express使用模板引擎,你必须告诉你的快递应用程序 将 'pug' 设置为'view-engine'。 app.set('view engine', 'pug')
最后,你应该改变请求您响应该指数路线res.render
与路径视图意见/哈巴狗/ index.pug。如果一切按计划进行,您应该刷新应用程序主页并看到一条小消息,说您已成功从我们的Pug文件中删除Pug!当您认为自己已经做对时,请提交您的页面。 Instructions
Tests
tests:
- text: 帕格是一个依赖
testString: 'getUserInput => $.get(getUserInput("url")+ "/_api/package.json") .then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, "pug", "Your project should list "pug" as a dependency"); }, xhr => { throw new Error(xhr.statusText); })'
- text: 查看引擎是帕格
testString: 'getUserInput => $.get(getUserInput("url")+ "/_api/server.js") .then(data => { assert.match(data, /("|")view engine("|"),( |)("|")pug("|")/gi, "Your project should set Pug as a view engine"); }, xhr => { throw new Error(xhr.statusText); })'
- text: 帕格正在工作
testString: 'getUserInput => $.get(getUserInput("url")+ "/") .then(data => { assert.match(data, /pug-success-message/gi, "Your projects home page should now be rendered by pug with the projects .pug file unaltered"); }, xhr => { throw new Error(xhr.statusText); })'
Challenge Seed
Solution
// solution required