-
Notifications
You must be signed in to change notification settings - Fork 3
Dynamic Views
Karen Coombs edited this page May 31, 2018
·
1 revision
Views can be use content to be dynamically generated. Data is passed into the view via an associative array. The key of the array is the name of the variable in the view.
Example:
res.render('display-user', {user: user});
- Open display-user.html
- Use user variable passed from route and User object methods to fill in fields in display-user.html
<%- include('header.html') -%>
<h1>Welcome <%= user.getGivenName()%></h1>
<div id="user">
<p>Name: <%= user.getFamilyName()%> <%= user.getGivenName()%></p>
<p>Email: <%= user.getEmail()%></p>
<p>ID/Namespace: <%= user.getOclcPPID()%> - <%= user.getOclcNamespace()%></p>
<p>Institution: <%= user.getInstitutionId()%></p>
</div>
<%- include('footer.html') -%>