-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from izolate/develop
- Loading branch information
Showing
9 changed files
with
2,637 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,8 @@ node_modules | |
.DS_Store | ||
|
||
# Test | ||
test.* | ||
index.html | ||
index.pug | ||
|
||
# Vim | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,69 @@ | ||
# html2pug | ||
Converts HTML to Pug (formerly Jade) | ||
Converts **HTML** to **Pug** templating language (_formerly Jade_). | ||
Requires Node.js version `7.6` or higher. | ||
|
||
Turns this :unamused: | ||
```html | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Hello World!</title> | ||
</head> | ||
<body> | ||
<div id="content"> | ||
<h1 class="title">Hello World!</h1> | ||
</header> | ||
</body> | ||
</html> | ||
``` | ||
|
||
Into this :tada: | ||
```pug | ||
!doctype html | ||
html(lang='en') | ||
head | ||
title Hello World! | ||
body | ||
#content | ||
h1.title Hello World! | ||
``` | ||
|
||
## Install | ||
|
||
Get it on npm: | ||
Get it on [npm](https://www.npmjs.com/package/html2pug): | ||
|
||
```bash | ||
npm i -g html2pug | ||
``` | ||
|
||
## Usage | ||
|
||
### CLI | ||
Accept input from a file and write to stdout: | ||
|
||
```bash | ||
html2pug < example.html | ||
``` | ||
|
||
Or write to a file: | ||
```bash | ||
html2pug -f /path/to/file.html | ||
html2pug < example.html > example.pug | ||
``` | ||
|
||
See `html2pug --help` for more information. | ||
|
||
### Programmatically | ||
|
||
```js | ||
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 |
Oops, something went wrong.