国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Web Front-end JS Tutorial Detailed explanation of the steps to use node front-end development template engine Jade

Detailed explanation of the steps to use node front-end development template engine Jade

May 22, 2018 am 10:32 AM
node engine template

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
//?如果成功返回版本號(hào)信息即為已成功安裝?Node?環(huán)境。
2. Install the Jade command line tool globally through npm

npm?install?jade?-g
//?mac用戶可能需要管理員權(quán)限,使用如下命令
sudo?npm?install?jade?-g
3. Create the *.Jade file and start the task.

4. Compile the jade file into an html file by using the Jade command line tool

How to use the Jade command line tool

We can view the parameters of the Jade command line tool through jade --help

jade?--help
Usage:?jade?[options]?[dir|file?...]
?Options:
??-h,?--help?????output?usage?information?/?輸出使用信息
??-V,?--version???output?the?version?number?/?輸出版本號(hào)信息
??-O,?--obj?<str>??javascript?options?object?/?傳輸?shù)?jade?文件中的數(shù)據(jù)對(duì)象
??-o,?--out?<dir>??output?the?compiled?html?to?<dir>?/?輸出編譯后的?HTML?到?<dir>?
??-p,?--path?<path>?filename?used?to?resolve?includes?/?在處理?stdio?時(shí),查找包含文件時(shí)的查找路徑
??-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)?/?關(guān)閉編譯的調(diào)試選項(xiàng)(函數(shù)會(huì)更小)
??-w,?--watch????watch?files?for?changes?and?automatically?re-render?/?監(jiān)聽文件改變并自動(dòng)刷新編譯結(jié)果
??--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:
??#?編譯整個(gè)目錄
??$?jade?templates
??#?生成?{foo,bar}.html
??$?jade?{foo,bar}.jade
??#?在標(biāo)準(zhǔn)IO下使用jade
??$?jade?< my.jade >?my.html
??#?在標(biāo)準(zhǔn)IO下使用jade
??$?echo?'h1?Jade!'?|?jade
??#?foo,?bar?目錄渲染到?/tmp
??$?jade?foo?bar?--out?/tmp
Example:

//?比如說(shuō)我們需要編譯index.jade文件,默認(rèn)編譯到同文件夾下的同名html?文件中
jade?index.jade
//?如果我們要格式化輸出?index.html?文件,只需要添加?-P?參數(shù)即可
jade?-P?index.jade
//?如果我們要實(shí)現(xiàn)監(jiān)聽和自動(dòng)編譯,需要使用?-w?參數(shù)
jade?-P?-w?index.jade
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to php Chinese Other related articles online!

Recommended reading:

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node? Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node? Mar 05, 2025 pm 05:57 PM

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

How to use express to handle file upload in node project How to use express to handle file upload in node project Mar 28, 2023 pm 07:28 PM

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!

An in-depth analysis of Node's process management tool 'pm2” An in-depth analysis of Node's process management tool 'pm2” Apr 03, 2023 pm 06:02 PM

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!

Token-based authentication with Angular and Node Token-based authentication with Angular and Node Sep 01, 2023 pm 02:01 PM

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

PHP email templates: customize and personalize your email content. PHP email templates: customize and personalize your email content. Sep 19, 2023 pm 01:21 PM

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

Template Metaprogramming in C++ FAQ Interview Questions Template Metaprogramming in C++ FAQ Interview Questions Aug 22, 2023 pm 03:33 PM

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

What is a single sign-on system? How to implement it using nodejs? What is a single sign-on system? How to implement it using nodejs? Feb 24, 2023 pm 07:33 PM

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!

How to add PPT mask How to add PPT mask Mar 20, 2024 pm 12:28 PM

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]

See all articles