All Projects → posthtml → posthtml-pug

posthtml / posthtml-pug

Licence: other
Pug Parser

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].