posthtml-pug
v1.0.2
Published
Pug Parser for PostHTML
Downloads
76
Readme
npm i -D posthtml-pug
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))
See the Pug API for a full description of the options that can be passed. By default the following options are set:
|Name|Default|
|:--:|:-----:|
|pretty
|true
|
|locals
|{}
|
index.pug
doctype html
html
head
meta(charset="utf8")
title Pug Parser
body
h1#title Pug for PostHTML
p= greeting
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Pug Parser</title>
</head>
<body>
<h1 id="title">Pug for PostHTML</h1>
<p>Hello!</p>
</body>
</html>