美文网首页
2018-09-10 Section 24 Intermedia

2018-09-10 Section 24 Intermedia

作者: tidibubu | 来源:发表于2018-09-13 04:12 被阅读0次

    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

    相关文章

      网友评论

          本文标题:2018-09-10 Section 24 Intermedia

          本文链接:https://www.haomeiwen.com/subject/zfpygftx.html