3.0.0 • Published 7 years ago
html-pug-converter v3.0.0
html-pug-converter
Converts HTML to Pug templating language (formerly Jade).
Requires Node.js version 7.6 or higher.
Turns this :unamused:
<!doctype html>
<html lang="en">
<head>
<title>Hello World!</title>
</head>
<body>
<div id="content">
<h1 class="title">Hello World!</h1>
</div>
</body>
</html>Into this :tada:
doctype html
html(lang='en')
head
title Hello World!
body
#content
h1.title Hello World!Install
Get it on npm:
npm i -g html-pug-converterUsage
CLI
Accept input from a file and write to stdout:
html-pug-converter < example.htmlOr write to a file:
html-pug-converter < example.html > example.pugSee html-pug-converter --help for more information.
Programmatically
const htmlPugConverter = require('html-pug-converter')
const html = '<header><h1 class="title">Hello World!</h1></header>'
const pug = htmlPugConverter(html, { tabs: true })Options
| Name | Type | Default | Description |
|---|---|---|---|
| tabs | Boolean | false | Use tabs instead of spaces |
| fragment | Boolean | false | Wrap in enclosing <html> and <body> tags |