Includes can help you create reusable pieces of content that will make it easier for you to build pages and reuse bits of content throughout your application.
- View Offline
- [Voiceover] In most websites, there are certain elements…that get repeated over and over, so it's a good idea…to split the content up into pieces.…Now for this, EJS provides an include command,…and it's really easy to use, and works just like…outputting a regular variable.…Now the way that I like to do my work,…I like to split up my content into little pieces…I call partials, small pieces of code…that I can reuse in different templates.…Some of my partials are just small pieces of HTML…that I can move around through different pages.…
So I create another section called Content,…where I put these kind of pages,…and I decide when I create a template…which pieces of content I'm going to need.…In addition to that, I usually create a section…called templates, and the rest of the content…that is essentially like script files or header information…that belongs in every page, I put in this section.…So what I'm gonna do first is just go back into my project…and in my Views folder, I'm going to create this structure.…
In this course, Ray Villalobos walks through the process of creating full-featured websites with these technologies. First, find out how to install each package and leverage Node.js features from within Express. Then learn how to build a basic application with templating engines like EJS; create more flexible, modular code with includes and conditional statements; build APIs to manage HTTP requests to add and delete content dynamically; and configure more complex routing. Along the way, Ray implements features like customer feedback forms and real-time live chat, so you can see exactly what Node.js and Express are capable of.
- Handling HTTP requests with Node.js and Express
- Creating and modularizing routes
- Using templates
- Building flexible views
- Creating an API route
- Dealing with POST and DELETE requests
- Creating live chat features with Socket.IO