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. css的再深入4(更新中···)

    两种居中的方式: Margin:0 auto;和text-align:center; Margin的居中是对自身,text-align对元素内部的文本来说. 隐藏的两种方式: visibility:h ...

  2. linux基础之vim编辑器

    vi : Visual Interface vim : VI Improved : VI的基础加上一些有用的插件 vim编辑器: 文本编辑器, 字处理器, 全屏编辑器, 模式化编辑器 vim的模式有三 ...

  3. LogStash Download

    https://www.elastic.co/downloads/logstash 1.Download and unzip Logstash 2.Prepare a logstash.conf co ...

  4. 一文读懂 深度强化学习算法 A3C (Actor-Critic Algorithm)

    一文读懂 深度强化学习算法 A3C (Actor-Critic Algorithm) 2017-12-25  16:29:19   对于 A3C 算法感觉自己总是一知半解,现将其梳理一下,记录在此,也 ...

  5. [POJ 2386] Lake Counting(DFS)

    Lake Counting Description Due to recent rains, water has pooled in various places in Farmer John's f ...

  6. parent获取子元素以及自身元素

    innerHTML 设置或获取位于对象起始和结束标签内的 HTML outerHTML 设置或获取对象及其内容的 HTML 形式 innerText 设置或获取位于对象起始和结束标签内的文本 oute ...

  7. 多线程tips(面试常用)

    描述线程和进程的区别? 我们运行一个exe,就是一个进程实例,系统中有很多个进程.每一个进程都有自己的内存地址空间,每个地址相当于一个独立的边界,有自己独占的资源,进程之间不能共享代码和数据空间.(可 ...

  8. Docker之Swarm

    Docker学习笔记 — Swarm搭建Docker集群 Swarm在schedule节点运行容器的时候,会根据指定的策略来计算最适合运行容器的节点,目前支持的策略有:spread, binpack, ...

  9. powerdesigner反转数据库的设计图

    PowerDesigner导入sql文件 1:点击 2:弹出该页面,点击确定 3:弹出一下页面,点击下面按钮选择文件 4:点击确定完成 二 .表转换为中文的执行脚本及步骤 执行脚本为:Option E ...

  10. error: could not create '/System/Library/Frameworks/Python.framework/Versions/2.7/share': Operation not permitted

    参考: Python pip安装模块报错 Mac升级到EI Captain之后pip install 无法使用问题 error: could not create '/System/Library/F ...