InterviewSolution
| 1. |
What Is Include And Components? |
|
Answer» Pug provides a very intuitive way to create components for a web page. For example, if you see a news website, the header with logo and categories is always fixed. Instead of copying that to evey view we create we can use an include. Following example shows how we can use an include: Create 3 views with the following code: HEADER.PUG div.header. I'm the header for this website. CONTENT.PUG html FOOTER.PUG div.footer. I'm the footer for this website. Create a route for this as follows: var koa = REQUIRE('koa'); Pug provides a very intuitive way to create components for a web page. For example, if you see a news website, the header with logo and categories is always fixed. Instead of copying that to evey view we create we can use an include. Following example shows how we can use an include: Create 3 views with the following code: HEADER.PUG div.header. I'm the header for this website. CONTENT.PUG html FOOTER.PUG div.footer. I'm the footer for this website. Create a route for this as follows: var koa = require('koa'); |
|