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 ...
随机推荐
- Python3 tkinter基础 Entry insert delete 点击按钮 向输入框赋值 或 清空
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Linux 使用statvfs读取文件系统信息
本文转载自:https://blog.csdn.net/papiping/article/details/6980573 在测试过程中,f_bfree的值比f_frsize的值大于10%的尺寸大小,意 ...
- MongoDB NoSQL 常用指令
查询 日期区间 db.<collections>.find({"service_name":"xxx"}).sort({ update_time:- ...
- 安装ubuntu的坑&RHEL7配置
1.需要其他设置->分区,分区需要有/根目录分区和swap空间,后者文件系统类型选择swap,其他都是ext4 2.普通配置电脑,安装16.04.5 LTS,不要安装最新的,安装重启后卡在那里, ...
- 集合01_List
List集合总览 元素有序,可重复,可通过索引访问 增加了通过索引操作集合的方法,如: Object get(int index) Object remove(int index) void sort ...
- [quartz] - Cron表达式举例
Quartz是一个任务调度框架.比如你遇到这样的问题 想每月25号,信用卡自动还款 想每年2月14日自己给当年暗恋女神发一封匿名贺卡 想每隔1小时,备份一下自己的SpringCloud学习笔记到云盘 ...
- c# 泛型的应用
泛型静态类 & function作为参数 /// <summary> /// /// </summary> /// <typeparam name="O ...
- HTML-CSS-JS-JQ常用知识点总结
html:展示文件 标签:<html><head><title></title><meta><link><style> ...
- 前端面试总结 (转 0C°)
前端面试总结 1.一些开放性题目 1.自我介绍:除了基本个人信息以外,面试官更想听的是你与众不同的地方和你的优势. 2.项目介绍 3.如何看待前端开发? 4.平时是如何学习前端开发的? 5.未来三到五 ...
- 转 这种方法可以免去自己计算大文件md5 的麻烦
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEditor;using ...