Converts HTML to Pug templating language (formerly Jade).
Requires Node.js version 7.6 or higher.
Turns this 😒
<!doctype html><htmllang="en"><head><title>Hello World!</title></head><body><divid="content"><h1class="title">Hello World!</h1></div></body></html>Into this 🎉
doctype html
html(lang='en')
head
title Hello World!
body
#content
h1.title Hello World!Get it on npm:
npm install -g html2pugAccept input from a file or stdin and write to stdout:
# choose a file
html2pug < example.html
# use pipeecho'<h1>foo</h1>'| html2pug -fWrite output to a file:
html2pug < example.html > example.pugSee html2pug --help for more information.
consthtml2pug=require('html2pug')consthtml='<header><h1 class="title">Hello World!</h1></header>'constpug=html2pug(html,{tabs: true})| 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 |