1.0.2 • Published 8 years ago

posthtml-pug v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

npm node deps tests coverage code style chat

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:

NameDefault
prettytrue
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>