


Detailed explanation of the steps to use node front-end development template engine Jade
This time I will bring you node front-end developmentTemplate engineDetailed explanation of the steps to use Jade, node front-end development template engine JadeWhat are the precautions, the following is a practical case, one Get up and take a look.
With the development of the web, front-end applications have become more and more complex, and back-end-based javascript(Node.js) has also begun to emerge. At this time, greater expectations are placed on javascript. At the same time, the idea of javascript MVC also became popular. In order to separate the user interface from business data (content), the concept of "template engine" was born.
To put it simply, the template engine is a string with several variables to be determined, and the data is dynamically stuffed into it through the template engine function.
Today we will talk about the usage and grammar instructions of Jade. Jade official website: jade-lang.com/Jade command line tool
The use of Jade requires the Node environment and is installed through the npm package Jade command line tool, after successful installation, you can create a new file with the file suffix *.jade. We can use jade's syntax to our heart's content. After writing, we only need to compile it through the command line tool to compile it into the html static file we usually use.Installation method
1. First determine whether the Node environment and npm tool are installed. The check method is as follows: Execute as follows in the command line tool Code:node -v => v0.10.35 npm -v => 1.4.28 // 如果成功返回版本号信息即为已成功安装 Node 环境。
npm install jade -g // mac用户可能需要管理员权限,使用如下命令 sudo npm install jade -g
How to use the Jade command line tool
We can view the parameters of the Jade command line tool through jade --helpjade --help Usage: jade [options] [dir|file ...] Options: -h, --help output usage information / 输出使用信息 -V, --version output the version number / 输出版本号信息 -O, --obj <str> javascript options object / 传输到 jade 文件中的数据对象 -o, --out <dir> output the compiled html to <dir> / 输出编译后的 HTML 到 <dir> -p, --path <path> filename used to resolve includes / 在处理 stdio 时,查找包含文件时的查找路径 -P, --pretty compile pretty html output / 格式化编译 html 文件 -c, --client compile function for client-side runtime.js / 编译浏览器端可用的 runtime.js -n, --name <str> The name of the compiled template (requires --client) / 编译模板的名字 -D, --no-debug compile without debugging (smaller functions) / 关闭编译的调试选项(函数会更小) -w, --watch watch files for changes and automatically re-render / 监听文件改变并自动刷新编译结果 --name-after-file Name the template after the last section of the file path (requires --client and overriden by --name) --doctype <str> Specify the doctype on the command line (useful if it is not specified by the template) / 在命令行中指定文档类型(如果在模板中没有被指定) Examples: # 编译整个目录 $ jade templates # 生成 {foo,bar}.html $ jade {foo,bar}.jade # 在标准IO下使用jade $ jade < my.jade > my.html # 在标准IO下使用jade $ echo 'h1 Jade!' | jade # foo, bar 目录渲染到 /tmp $ jade foo bar --out /tmp
// 比如说我们需要编译index.jade文件,默认编译到同文件夹下的同名html 文件中 jade index.jade // 如果我们要格式化输出 index.html 文件,只需要添加 -P 参数即可 jade -P index.jade // 如果我们要实现监听和自动编译,需要使用 -w 参数 jade -P -w index.jade
detailed explanation of the use of Jade tags in node front-end template engine
nodeJS server creation and restart operation code sharing
The above is the detailed content of Detailed explanation of the steps to use node front-end development template engine Jade. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to handle file upload? The following article will introduce to you how to use express to handle file uploads in the node project. I hope it will be helpful to you!

This article will share with you Node's process management tool "pm2", and talk about why pm2 is needed, how to install and use pm2, I hope it will be helpful to everyone!

Detailed explanation and installation guide for PiNetwork nodes This article will introduce the PiNetwork ecosystem in detail - Pi nodes, a key role in the PiNetwork ecosystem, and provide complete steps for installation and configuration. After the launch of the PiNetwork blockchain test network, Pi nodes have become an important part of many pioneers actively participating in the testing, preparing for the upcoming main network release. If you don’t know PiNetwork yet, please refer to what is Picoin? What is the price for listing? Pi usage, mining and security analysis. What is PiNetwork? The PiNetwork project started in 2019 and owns its exclusive cryptocurrency Pi Coin. The project aims to create a one that everyone can participate

PHP email templates: Customize and personalize your email content With the popularity and widespread use of email, traditional email templates can no longer meet people's needs for personalized and customized email content. Now we can create customized and personalized email templates by using PHP programming language. This article will show you how to use PHP to achieve this goal, and provide some specific code examples. 1. Create an email template First, we need to create a basic email template. This template can be an HTM

Authentication is one of the most important parts of any web application. This tutorial discusses token-based authentication systems and how they differ from traditional login systems. By the end of this tutorial, you will see a fully working demo written in Angular and Node.js. Traditional Authentication Systems Before moving on to token-based authentication systems, let’s take a look at traditional authentication systems. The user provides their username and password in the login form and clicks Login. After making the request, authenticate the user on the backend by querying the database. If the request is valid, a session is created using the user information obtained from the database, and the session information is returned in the response header so that the session ID is stored in the browser. Provides access to applications subject to

What is a single sign-on system? How to implement it using nodejs? The following article will introduce to you how to use node to implement a single sign-on system. I hope it will be helpful to you!

Regarding PPT masking, many people must be unfamiliar with it. Most people do not understand it thoroughly when making PPT, but just make it up to make what they like. Therefore, many people do not know what PPT masking means, nor do they understand it. I know what this mask does, and I don’t even know that it can make the picture less monotonous. Friends who want to learn, come and learn, and add some PPT masks to your PPT pictures. Make it less monotonous. So, how to add a PPT mask? Please read below. 1. First we open PPT, select a blank picture, then right-click [Set Background Format] and select a solid color. 2. Click [Insert], word art, enter the word 3. Click [Insert], click [Shape]

C++ is a programming language widely used in various fields. Its template metaprogramming is an advanced programming technique that allows programmers to transform types and values at compile time. Template metaprogramming is a widely discussed topic in C++, so questions related to it are quite common in interviews. Here are some common template metaprogramming interview questions in C++ that you may be asked. What is template metaprogramming? Template metaprogramming is a technique for manipulating types and values at compile time. It uses templates and metafunctions to generate based on types and values
