html2pug
Converts HTML to Pug
Last updated a year ago by izolate .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install html2pug 
SYNC missed versions from official npm registry.

html2pug Build Status

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 install -g html2pug

Usage

CLI

Accept input from a file or stdin and write to stdout:

# choose a file
html2pug < example.html

# use pipe
echo '<h1>foo</h1>' | html2pug -f

Write output 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 for indentation
commas Boolean true Use commas to separate node attributes
doubleQuotes Boolean false Use double quotes instead of single quotes for attribute values
fragment Boolean false Wraps result in enclosing <html> and <body> tags if false

Current Tags

  • 4.0.0                                ...           latest (a year ago)

7 Versions

  • 4.0.0                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.0.1                                ...           4 years ago
  • 0.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 4
Dependencies (4)
Dev Dependencies (9)

Copyright 2014 - 2017 © taobao.org |