-
Notifications
You must be signed in to change notification settings - Fork 0
Views
Luis Eduardo Brito edited this page Sep 4, 2013
·
1 revision
Views are rendered using the ejs
module, but are wrapped in the Response Adapter calling the method response(res).view()
, where res is the response object passed to the controller by the Router.
Sample Home Controller /api/controllers/home.js
module.exports = {
index: function(req, res) {
response(res).view("home/index", {
title: "node-web-cluster",
message: "welcome!"
});
},
}
Sample Home View
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><%- title %></title>
</head>
<body>
<%- message %>
</body>
</html>
Result:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>node-web-cluster</title>
</head>
<body>
welcome!
</body>
</html>