Express ~ Templating - rohit120582sharma/Documentation GitHub Wiki

Views allow you to dynamically render HTML. This both allows you to change the HTML on the fly and to write the HTML in other languages.

Express has a view system that can dynamically render HTML pages. You call response.render to dynamically render a view with some variables. Before doing this, you must configure Express to use the right template engine in the right folder.

Many templating engines have been ported to work with Express. A popular one is called EJS, which is the simplest for folks who know already HTML.

app.get('/', (req, res)=>{
	res.render('index', {
		message: 'Hey everyone! This is my webpage.'
	});
});
<!-- index.ejs -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Hello, world!</title>
	</head>
	<body>
		<%= message %>
	</body>
</html>
⚠️ **GitHub.com Fallback** ⚠️