Node.JS: Engine EJS

Embedded JavaScript templating (EJS)

Similar to express to install EJS in a repository use the command:

npm install ejs -save

Since the project that will be created will have a considered size lets use pastes to store the files and have a better organization in the project.

For the app.js use:
app.set(‘view engine’, ‘ejs’)- this will set the view engine as ejs.

For the index.js use:

var express = require(‘express’); var app = express();app.set(‘view engine’, ‘ejs’); app.get(‘/’,function(req,res){ res.render(“./home/index”);}); app.get(‘/registo’,function(req,res){ res.render(“./registo/form_registo”);}); app.listen(8080,function(){ console.log(“Servidor ativo no porto 8080”);});




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to build a recipe app using Vue.js and Vuex

Visual Regression Testing with BackstopJS in a Docker container

Recreating Promises in Javascript

Ерата на Метавселената приближава! Bit.Country организира аирдроп на токени NUUM

TypeScript - Taking JavaScript One Step Further

Run your python script with arguments

React & TypeScript: TS2345: Argument of type ‘null’ is not assignable to parameter of type…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
João Saraiva

João Saraiva

More from Medium

React and Fastify — Perfect Companions

Reactify, merge React with Fastify

End to end testing with NodeJS using CodeceptJS with real world example — Part 2(a): Locating…

Validate schema for requests in Express Node js using JOI middleware

Node Version Manager