X Tutup
The Wayback Machine - https://web.archive.org/web/20201205061732/https://github.com/posthtml/posthtml-pug
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

npm node deps tests coverage code style chat

Pug

Parser for PostHTML

Install

npm i -D posthtml-pug

Usage

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

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>

Maintainer


Michael Ciniawsky

Contributors


Jeff Escalante

Timothy Gu
You can’t perform that action at this time.
X Tutup