npm
express
dynamic templating
handlebars
javascript
5 years, 2 months ago
//app.js
const path = require("path");
const express = require("express")
const app = express()
const port = 3000
app.set('view engine', 'hbs')
app.get('', (req, res) => {
res.render('index',{
title: 'Dynamic template, HandleBars',
content: 'Koderplace'
})
})
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
//index.hbs
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1>{{title}}</h1>
<div>created by {{content}}</div>
</body>
</html>
0 Comments
Please Login to Comment Here