Skip to content

mvpashkov/html2pug

 
 

Repository files navigation

html2pug

Converts HTML to Pug templating language (formerly Jade).
Requires Node.js version 7.6 or higher.

Turns this 😒

<!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 🎉

doctype html
html(lang='en')
  head
    title Hello World!
   body
    #content
      h1.title Hello World!

Install

Get it on npm:

npm i -g html2pug

Usage

CLI

Accept input from a file and write to stdout:

html2pug < example.html

Or write to a file:

html2pug < example.html > example.pug

See html2pug --help for more information.

Programmatically

const html2pug = require('html2pug')

const html = '<header><h1 class="title">Hello World!</h1></header>'
const pug = html2pug(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

About

Converts HTML to Pug 🐶

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%