https://github.com/posthtml/posthtml-pug
Pug Parser
https://github.com/posthtml/posthtml-pug
Last synced: 10 months ago
JSON representation
Pug Parser
- Host: GitHub
- URL: https://github.com/posthtml/posthtml-pug
- Owner: posthtml
- License: other
- Created: 2016-03-03T05:43:23.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-03-19T09:34:32.000Z (almost 8 years ago)
- Last Synced: 2025-04-22T00:27:32.321Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 35.2 KB
- Stars: 17
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[![npm][npm]][npm-url]
[![node][node]][node-url]
[![deps][deps]][deps-url]
[![tests][tests]][tests-url]
[![coverage][cover]][cover-url]
[![code style][style]][style-url]
[![chat][chat]][chat-badge]
Pug
Parser for PostHTML
Install
```bash
npm i -D posthtml-pug
```
Usage
```js
import { readFileSync } from ('fs')
import pug from 'posthtml-pug'
import posthtml from 'posthtml'
const file = readFileSync('./index.pug', 'utf8')
posthtml()
.process(file, { parser: pug({ locals: {} }) })
.then((result) => console.log(result.html))
```
Options
See the [Pug API](https://pugjs.org/api/reference.html) for a full description of the options that can be passed.
By default the following options are set:
|Name|Default|
|:--:|:-----:|
|**`pretty`**|`true`|
|**`locals`**|`{}`|
Example
**index.pug**
```pug
doctype html
html
head
meta(charset="utf8")
title Pug Parser
body
h1#title Pug for PostHTML
p= greeting
```
### 
```js
import { readFileSync } from ('fs')
import pug from 'posthtml-pug'
import posthtml from 'posthtml'
const file = readFileSync('./index.pug', 'utf8')
const locals = { greeting: 'Hello!' }
posthtml()
.process(file, { parser: pug({ locals: locals }) })
.then((result) => console.log(result.html))
```
**index.html**
```html
Pug Parser
Pug for PostHTML
Hello!
```
Maintainer
Contributors
[npm]: https://img.shields.io/npm/v/posthtml-pug.svg
[npm-url]: https://npmjs.com/package/posthtml-pug
[node]: https://img.shields.io/node/v/posthtml-load-options.svg
[node-url]: https://nodejs.org/
[deps]: https://david-dm.org/posthtml/posthtml-pug.svg
[deps-url]: https://david-dm.org/posthtml/posthtml-pug
[tests]: http://img.shields.io/travis/posthtml/posthtml-pug.svg
[tests-url]: https://travis-ci.org/posthtml/posthtml-pug
[cover]: https://coveralls.io/repos/github/posthtml/posthtml-pug/badge.svg?branch=master
[cover-url]: https://coveralls.io/github/posthtml/posthtml-pug?branch=master
[style]: https://img.shields.io/badge/code%20style-standard-yellow.svg
[style-url]: http://standardjs.com/
[chat]: https://badges.gitter.im/posthtml/posthtml.svg
[chat-badge]: https://gitter.im/posthtml/posthtml?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"