pug
and pug-cli
In this part of the pug tutorial series we will learn about getting started with pug. We will learn how to install pug.
Prerequisites for getting started with pug are as follows :
node.js
using the
following command :
>node -v
v8.5.0
node.js
from our node.js tutorial series 30 days of node .
node.js
.
You can check the version number of the installed npm
using the following command :
>npm -v
5.5.1
pug
.
>npm install pug -g
here -g just signifies the global installation of pug npm package. You can install locally or gloablly as per your requirements.
pug-cli
npm package is used to render file/files or all files in a particular directory.
Also if no files are specified it can take input from standard input
and provides output on standard output
>npm install pug-cli -g
Following are the options provided by pug-cli :
>pug -h
-h, --help output usage information
-V, --version output the version number
-O, --obj <str|path> JSON/JavaScript options object or file
-o, --out <dir> output the rendered HTML or compiled JavaScript to
<dir>
-p, --path <path> filename used to resolve includes
-P, --pretty compile pretty HTML output
-c, --client compile function for client-side 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
-E, --extension <ext> specify the output file extension
-s, --silent do not output logs
--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)
Checking the version of the pug
and pug-cli
:
>pug -V
pug version: 2.0.0-rc.4
pug-cli version: 1.0.0-alpha6
In this article we learn about the prerequisites for installing pug. We also learn how we can install pug
and pug-cli
. Also we learn about all the options provided by pug-cli
with the help of a simple
example.