npmのサイトに沿って進めます。node.jsは最新版が必要。先ほど10.7.0にupdateしたばかり。
https://www.npmjs.com/package/pug
[vagrant@localhost python]$ npm install pug
npm WARN saveError ENOENT: no such file or directory, open ‘/home/vagrant/python/package.json’
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open ‘/home/vagrant/python/package.json’
npm WARN python No description
npm WARN python No repository field.
npm WARN python No README data
npm WARN python No license field.
+ pug@2.0.3
added 62 packages from 140 contributors and audited 104 packages in 11.406s
found 0 vulnerabilities
[vagrant@localhost python]$ npm install pug-cli -g
/home/vagrant/.nvm/versions/node/v10.7.0/bin/pug -> /home/vagrant/.nvm/versions/node/v10.7.0/lib/node_modules/pug-cli/index.js
+ pug-cli@1.0.0-alpha6
added 73 packages from 140 contributors in 5.131s
なんじゃこりゃー
[vagrant@localhost python]$ pug –help
Usage: pug [options] [dir|file …]
Options:
-V, –version output the version number
-O, –obj
-o, –out
-p, –path
-b, –basedir
-P, –pretty compile pretty HTML output
-c, –client compile function for client-side
-n, –name
-D, –no-debug compile without debugging (smaller functions)
-w, –watch watch files for changes and automatically re-render
-E, –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
-h, –help output usage information
Examples:
# Render all files in the `templates` directory:
$ pug templates
# Create {foo,bar}.html:
$ pug {foo,bar}.pug
# Using `pug` over standard input and output streams
$ pug < my.pug > my.html
$ echo ‘h1 Pug!’ | pug
# Render all files in `foo` and `bar` directories to `/tmp`:
$ pug foo bar –out /tmp
# Specify options through a string:
$ pug -O ‘{“doctype”: “html”}’ foo.pug
# or, using JavaScript instead of JSON
$ pug -O “{doctype: ‘html’}” foo.pug
# Specify options through a file:
$ echo “exports.doctype = ‘html’;” > options.js
$ pug -O options.js foo.pug
# or, JSON works too
$ echo ‘{“doctype”: “html”}’ > options.json
$ pug -O options.json foo.pug