An open API service indexing awesome lists of open source software.

https://github.com/posthtml/posthtml-pug

Pug Parser
https://github.com/posthtml/posthtml-pug

Last synced: 10 months ago
JSON representation

Pug Parser

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







Michael Ciniawsky


Contributors







Jeff Escalante





Timothy Gu


[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"