Template Engines: Pug and Handlebars

一个模版引擎是一个库或框架。它用一些rules/languages来解释data和渲染views。

web app中,views可能是HTML pages(或部分它们),但是也可以是JSON, XML文件, 或者在desktop programs中是GUIs。

MVC框架,templates属于view。

在web app内,使用模版可以动态地生成无限多个pages。

之后讲如何使用Pug和Handlebars

然后是:

Project: Adding Pug Templates to Blog

  • layout.pug: Global app-wide template
  • index.pug: Home page with the list of posts
  • article.pug: Individual article page
  • login.pug: Page with a login form
  • post.pug: Page for adding a new article
  • admin.pug: Page to administer articles after logging in

Because the templates in this mini-project require data, we'll skip the demo until Chapter 5, where we'll plug in the MongoDB database. So the source code for the Pug templates is exactly the same as in the code/ch5 folder of the GitHub repository azat-co/practicalnodehttps://github.com/azat-co/practicalnode. Feel free to copy it from there or follow the instructions to implement listed below in this section.

Practical Node.js (2018版) 第4章: 模版引擎的更多相关文章

  1. Practical Node.js (2018版) 第7章:Boosting Node.js and Mongoose

    参考:博客 https://www.cnblogs.com/chentianwei/p/10268346.html 参考: mongoose官网(https://mongoosejs.com/docs ...

  2. Practical Node.js (2018版) 第5章:数据库 使用MongoDB和Mongoose,或者node.js的native驱动。

    Persistence with MongoDB and Mongoose https://github.com/azat-co/practicalnode/blob/master/chapter5/ ...

  3. Practical Node.js (2018版) 第10章:Getting Node.js Apps Production Ready

    Getting Node.js Apps Production Ready 部署程序需要知道的方面: Environment variables Express.js in production So ...

  4. Practical Node.js (2018版) 第9章: 使用WebSocket建立实时程序,原生的WebSocket使用介绍,Socket.IO的基本使用介绍。

    Real-Time Apps with WebSocket, Socket.IO, and DerbyJS 实时程序的使用变得越来越广泛,如传统的交易,游戏,社交,开发工具DevOps tools, ...

  5. Practical Node.js (2018版) 第3章:测试/Mocha.js, Chai.js, Expect.js

    TDD and BDD for Node.js with Mocha TDD测试驱动开发.自动测试代码. BDD: behavior-driven development行为驱动开发,基于TDD.一种 ...

  6. Practical Node.js (2018版) 第8章:Building Node.js REST API Servers

    Building Node.js REST API Servers with Express.js and Hapi Modern-day web developers use an architec ...

  7. Practical Node.js (2018版) 13章, Node HTTP/2 Servers

    新增的章节. If you are not using HTTP/2, then you are losing out on big improvements. HTTP/2相比http/1有很大的区 ...

  8. Practical Node.js (2018版) 14章, async code in Node

    Asynchronous Code in Node 历史上,Node开发者只能用回调和事件emitters. 现在可以使用一些异步的语法: async module Promises Async/aw ...

  9. Practical Node.js摘录(2018版)第1,2章。

    大神的node书,免费 视频:https://node.university/courses/short-lectures/lectures/3949510 另一本书:全栈JavaScript,学习b ...

随机推荐

  1. django基础 -- 9.中间件

    一.中间件的介绍 中间件顾名思义,是介于request与response处理之间的一道处理过程,相对比较轻量级, 并且在全局上改变django的输入与输出.因为改变的是全局,所以需要谨慎实用, 用不好 ...

  2. ScheduledTheadPool线程池的使用

    ScheduledTheadPool线程池的特点在于可以延迟执行任务,也可以周期性执行任务. 创建线程池 ScheduledExecutorService scheduled = Executors. ...

  3. Junit中AssertTrue的使用

    assertTrue public static void assertTrue(String message, boolean condition) Asserts that a condition ...

  4. 压测freeswitch--安装sipp

    1.sipp下载 下载链接:https://sourceforge.net/projects/sipp/files/ 此处我们下载sipp3.3为例 2.linux系统下编译sipp 安装sipp 可 ...

  5. 2-sat相关复习

    2-sat相关复习 noi曾经考过,谁能说得准呢 sat问题 通俗的sat问题表述一般是这样的:有很多个集合,每个集合里面有若干元素,现给出一些取元素的规则,要你判断是否可行,可行则给出一个可行方案. ...

  6. 深度学习课程笔记(八)GAN 公式推导

    深度学习课程笔记(八)GAN 公式推导 2018-07-10  16:15:07

  7. NOI 2011 阿狸的打字机(AC自动机+主席树)

    题意 https://loj.ac/problem/2444 思路 ​多串匹配,考虑 \(\text{AC}\) 自动机.模拟打字的过程,先建出一棵 \(\text{Trie}\) 树,把它变成自动机 ...

  8. Spring Cloud各组件超时总结

    Ribbon的超时 全局设置: ribbon: ReadTimeout: 60000 ConnectTimeout: 60000 1 2 3 局部设置: service-id: ribbon: Rea ...

  9. sap hana 数据库 EBS

    SAP实时数据平台详解 ************************************************************ EBS是Oracle 公司对原有应用产品整合后的一个产 ...

  10. HDU 4309 Seikimatsu Occult Tonneru(最大流+二进制枚举)

    http://acm.hdu.edu.cn/showproblem.php?pid=4309 题意: 有n个城市,每个城市有num[i]个居民,有敌人要进行地毯式轰击,居民们要逃到隧道去.现在有隧道, ...