Lecture 3 - Templating and Persistence
Lecture 3 - Templating and Persistence
2537
Templating & Persistence
What is Templating? (1/5)
● Model contains assets (e.g., profile info, image gallery, media streams, etc.)
○ Can be hosted in the file system, DB, cloud, etc.
● View is represented by declarative syntax
○ And has an engine that interprets the code
○ Views or view components are represented as templates
■ Templates contain static information – such as look-and-feel data,
and placeholders
What is Templating? (3/5)
● Approach:
○ Use the server to perform all templating operations before handing
rendered views to the client
○ Uses JSDOM & jQuery on the server-side
○ Parts of the page (i.e., components) are split up
■ Could potentially come from other servers or services entirely!
○ Using JSDOM and jQuery on the server, replace placeholders with
dynamic content
Templating with Server-Side JS/DOM (2/2)
● Benefits:
○ User is unaware of any construction of view (encapsulation)
■ Can hide different services or different parts of a service
○ Less resources used on the client side
○ less chance of things breaking
● Server-side routing:
○ Answers the calls from client-side scripts
○ Accepts HTTP parameters in an elegant way
○ Allows for much more modular S/W development
● Client-side routing:
○ Inspired by server-side routing
○ Is sometimes a mixture of client and server-side
○ Makes client-side code easier to maintain
MVC Frameworks (1/3)