Jade模板

!!!
html
    head
        title #{title}
        meta(charset="UTF-8")
    body
        div.description #{description}
        ul
            - each data in datas
                li.item(id='item_'+data.index)
                    span= data.time
                    a.art(href=data.url)= data.title

ejs模板

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title><%=title%> - Page Test</title>
</head>
<body>
    <div class="description"><%=description%></div>
    <ul>
<% function data(data) { %>
        <li class="item" ><%=data.title%></a></li>
<% } %>
<% datas.map(data) %>
    </ul>

</body>
</html>

handlebars模板

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{{title}} - Page Test</title>
</head>
<body>
    <div class="description">{{description}}</div>
    <ul>
{{#datas}}
        <li class="item" >{{title}}</a></li>
{{/datas}}
    </ul>

</body>
</html>

express中默认安装的是jade模板,想要安装指定的模板,则需要运行命令:express -e xxx(项目名)

jade因为采用了类似zen code的语法,比较新奇,但效率极其低下。对jade,个人不建议,除了效率,另外一个主要原因是可视化太弱,甚至可以说是毫无可视化可言,学习成本高,维护与团队合作成本高,语法过于晦涩、复杂。

相关文章:

  • 2022-12-23
  • 2021-11-19
  • 2021-07-02
  • 2021-11-27
  • 2021-08-02
  • 2021-10-22
猜你喜欢
  • 2022-01-25
  • 2022-01-18
  • 2021-09-06
  • 2021-08-28
  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案