© Jörg Krause 2017

Jörg Krause, Programming Web Applications with Node, Express and Pug , 10.1007/978-1-4842-2511-0_8

8. The Pug Command Line

Jörg Krause

(1)Berlin, Germany

The command line can use auxiliary functions directly, for example translating sites into static HTML at first.

Installing the Command Line

The installation takes place via npm (-g stands for global).

1   $ npm install pug -g
A435076_1_En_8_Figa_HTML.jpg CLI

Command line tools are often called “CLI”: Command Line Interface.

Use and Options

The use of the command line looks as follows:

1   $ pug [options] [dir|file ...]
Table 8-1. Options of Pug-CLI

Options

-h, --help

help for usage

-V,  --version

version of the library

-O,  --obj  <path|str>

JavaScript options or JSON file with a suitable object inside

-o, --out <dir>

edition listing for the HTML

-p,  --path  <path>

file path for dissolving ‘ includes ‘

-P, --pretty

HTML edition is arranged readable

-c, --client

translation functions for the client page runtime.js

-n,  --name  <str>

the name of the translated template (requires – client )

-D,  --no-debug

translate without debuggers (smaller functions)

-w,  --watch

supervises files on changes and renders again

-E,  --extension  <ext>

indicates the file extension for the edition

--name-after-file

name of the template after the last segment of the file path during (requires – client, overwritten by –name)

--doctype  <str>

determines the doctype on the command line (meaningful, if the template)

Sample Applications for the Command Line

Translate templates locally as follows:

1   $ pug templates

To produce two HTML files, “foo.html” and “bar.html”, thew following command will work:

1   $ pug {foo,bar}.pug

Pug results can be shown via “stdio”:

1   $ pug <my.pug> my.html

A bypass to Pug takes place via the pipe symbol:

1   $ echo "h1 pug!" | pug

Render the listings “foo” and “bar” after /tmp:

1   $ pug foo bar --out /tmp
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.17.140