2018-09-10 Section 24 Intermediate Express

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


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的阅读 13,526评论 5 6
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,424评论 0 10
  • Getting Started Use the Current Stable Version (7.1) Buil...
    Leonzai阅读 1,970评论 0 3
  • 凌晨时分,翻来覆去,辗转难眠。屋内漆黑一片,父亲的鼾声夹杂着呓语,一阵阵传来。睁开眼,呆呆的直视着黑茫茫的夜,...
    竹鸿初阅读 328评论 2 0
  • 有些事,不用太早下结论。 当你的声音没有在你预想的时间内被回复时, 你能做的就是, 不要用臆想去猜测, 然后, 在...
    施小施阅读 229评论 0 0