Practical Node.js (2018版) 第4章: 模版引擎
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 templateindex.pug
: Home page with the list of postsarticle.pug
: Individual article pagelogin.pug
: Page with a login formpost.pug
: Page for adding a new articleadmin.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/practicalnode
: https://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章: 模版引擎的更多相关文章
- Practical Node.js (2018版) 第7章:Boosting Node.js and Mongoose
参考:博客 https://www.cnblogs.com/chentianwei/p/10268346.html 参考: mongoose官网(https://mongoosejs.com/docs ...
- Practical Node.js (2018版) 第5章:数据库 使用MongoDB和Mongoose,或者node.js的native驱动。
Persistence with MongoDB and Mongoose https://github.com/azat-co/practicalnode/blob/master/chapter5/ ...
- Practical Node.js (2018版) 第10章:Getting Node.js Apps Production Ready
Getting Node.js Apps Production Ready 部署程序需要知道的方面: Environment variables Express.js in production So ...
- Practical Node.js (2018版) 第9章: 使用WebSocket建立实时程序,原生的WebSocket使用介绍,Socket.IO的基本使用介绍。
Real-Time Apps with WebSocket, Socket.IO, and DerbyJS 实时程序的使用变得越来越广泛,如传统的交易,游戏,社交,开发工具DevOps tools, ...
- 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.一种 ...
- 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 ...
- 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有很大的区 ...
- Practical Node.js (2018版) 14章, async code in Node
Asynchronous Code in Node 历史上,Node开发者只能用回调和事件emitters. 现在可以使用一些异步的语法: async module Promises Async/aw ...
- Practical Node.js摘录(2018版)第1,2章。
大神的node书,免费 视频:https://node.university/courses/short-lectures/lectures/3949510 另一本书:全栈JavaScript,学习b ...
随机推荐
- linux下如何删除行首的数字?
举例如下: 1.某文件jello.txt中有以下行 1111-yes 2222-no 3333-yes-no-no 2.删除jello.txt中每行行首的数字 cat jello.txt | cut ...
- 日志统计 尺取法【蓝桥杯2018 C/C++ B组】
标题:日志统计 小明维护着一个程序员论坛.现在他收集了一份"点赞"日志,日志共有N行.其中每一行的格式是: ts id 表示在ts时刻编号id的帖子收到一个"赞" ...
- Ubuntu 使用unzip解压乱码的问题
由于win使用的是GBK编码,在win下打包zip的压缩文件在ubuntu下使用unzip解压会出现乱码的问题. 解决方案: 换软件,不用unzip,使用unar 18.04是默认安装的,如果没有默认 ...
- 最后一次谈 VirtualBox的安装方法
用 VirtualBox....run 或 .rpm安装都可以, 最重要的是要 用 /usr/sbin/vboxconfig -> vboxdrv.sh --> 去创建 VirutalBo ...
- 【Dalston】【第二章】客户端负载均衡(Ribbon)
对于大型应用系统负载均衡(LB:Load Balancing)是首要被解决一个问题.在微服务之前LB方案主要是集中式负载均衡方案,在服务消费者和服务提供者之间又一个独立的LB,LB通常是专门的硬件,如 ...
- java 反射工具
<dependency> <groupId>org.reflections</groupId> <artifactId>reflections</ ...
- [LightOJ 1341] Aladdin and the Flying Carpet (算数基本定理(唯一分解定理))
题目链接: https://vjudge.net/problem/LightOJ-1341 题目描述: 问有几种边长为整数的矩形面积等于a,且矩形的短边不小于b 算数基本定理的知识点:https:// ...
- Latex: extra alignment tab has been changed to cr
参考: Error: extra alignment tab has been changed to \cr Latex: extra alignment tab has been changed t ...
- usart2 重映射
今天拾起闲置很久的灰机,测试发现nrf2401坏掉,重新淘宝.还发现机上搭载的usart1坏掉,换成usart2,发现端口被电机占用,重映射到PD5,PD6 关键是后面两句不要忘记了 RCC_APB1 ...
- win7 "com surrogate“ 已停止工作的解决办法
1.在文件夹选项里选“始终显示图标,从不显示缩略图”. 2.数据执行保护(DEB),依次打开:计算机——属性——高级系统设置——高级——性能——设置——数据执行保护 选下面的单选按钮“为除下列选定程序 ...