From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Rendering template on server - Nest.js Tutorial
From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Rendering template on server
Alright, to begin with, we are going to focus on rendering templates on the server and then we will gradually attach MySQL to them. So let's see how to render a template. We will need to install two important packages. I'll give the command npm install at nestjs slash platform hyphen express and the templating engine ejs. Now after installing these packages, I'll create a views folder inside the root directory and define a file named home.ejs. I'll give the steady HTML boilerplate, I'll change the title to my store, and we'll give an h1 and the scriptlet with a message variable. Now in the app controller, I'll give the get route handler with a route path set to my store, and a method render page. Defining this inside the app controller because the app controller is going to get bootstrapped first when the application is rendered. So we will keep the homepage inside the app controller. Inside this method, I will return an object with the message property, welcome to homepage. So we are…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Introduction to MyStore application2m 43s
-
(Locked)
Rendering template on server4m 41s
-
(Locked)
Creating navbar with "includes"3m 31s
-
(Locked)
Creating home interface9m 6s
-
(Locked)
Conditional rendering: No product found2m 26s
-
(Locked)
Configuring add product route2m 29s
-
(Locked)
Creating "add product" interface5m 51s
-
(Locked)
Configuring edit product route1m 49s
-
(Locked)
Interface & functionality: Edit product4m 10s
-
(Locked)
-
-
-
-