3.0.0 • Published 5 years ago

html-pug-converter v3.0.0

Weekly downloads
503
License
MIT
Repository
github
Last release
5 years ago

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-converter

Usage

CLI

Accept input from a file and write to stdout:

html-pug-converter < example.html

Or write to a file:

html-pug-converter < example.html > example.pug

See 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

NameTypeDefaultDescription
tabsBooleanfalseUse tabs instead of spaces
fragmentBooleanfalseWrap in enclosing <html> and <body> tags
3.0.0

5 years ago

1.0.0

5 years ago