You are on page 1of 17

View Engine

Trần Thị Bích Hạnh


Cơ chế truyền nhận dữ liệu
Client – Web Server
Client
• HTTP Methods: Post, Get, Put, Delete
• URL
• Querystring • Hyperlink
• Params • Form submit
• Body • ajax

Server
• ROUTES: app.get, app.put, app.post, app.delete HTML
• REQUEST: req.query, req.params, req.body
• RESPONSE: res.send, res.render JSON
Response Methods
ExpressJS
Handlebars JS

£ Logic-less Template engine


£ Hỗ trợ Data Binding vào một template để
hiển thị ra website
£ Cài đặt:
Sử dụng Handlebars
với Express JS
Layouts
views/layouts/main.hbs
views/index.hbs

res.render(‘index’);
Partials
views/layouts/main.hbs
views/index.hbs

res.render(‘index’);
{{> header}}

{{> footer}}
Expression
Condition (if)
Condition (unless)
Iteration (each)
HTML Escape
HTML Escape Output
With
With Output
Comment

You might also like