Templates and EJS
#Rendering HTML and Templates
1, Use res.render() to render Html (from an EJS file)
2,Explain what EJS is and why we use it
embedded javascrpt, EJS是一个JavaScript模板库,用来从JSON数据中生成HTML字符串。
3,Pass variables to EJStemplates
app.js
love.ejs
#EJS control Flow
1, Show examples of control flow in EJS templates
<%= %> equal sign will take the return value and stick it in HTML
<% %> no equal will just run the code
2,Write if statements in an EJS file
3Write loops in an EJS file
#Styles and partials
1 show how to properly include public assets
2, properly configure our app to use EJS
3 Use partials to dry up our code
ejs file
header.ejs
footer.ejs
#post Requsts!!
1, write post routes, and test them with postman
2,use a form to send a post request
3 use body parser to get form data
网友评论