1.1.0 • Published 7 years ago

express-posthtml v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

npm deps tests coverage code style chat

npm i -S express-posthtml

Engine

Register PostHTML as Express View Engine

app.engine('html', require('express-posthtml'))
NameTypeDefaultDescription
plugins{Array}[]PostHTML Plugins
options{Object}{}PostHTML Options

Global

All views will render with this setup, if no local setup provided.

app.set('view options', { plugins: [], options: {} })
res.render('file.ext')

Local

View specific setup by adding plugins separately to the respective routes. Note that if you have set plugins globally, routes with local setup will not use the global setup by default.

app.set('view options', { options: { parser: pug }})
res.render('file.pug', { plugins: [...plugins] })

Extend

If views share common plugins (e.g for BEM Support), but view specific additions are necessary, use the extend option. Now the global setup is used and will be extended with the local plugins of the respective route.

app.set('view options', { plugins: [...plugins], options: {} })
res.render('file', { plugins: [/* PostHTML Plugins */], extend: true })
import express from 'express'
import posthtml from 'express-posthtml'

const app = express()

app.engine('html', require('posthtml'))

const plugins = [
  require('posthtml-bem')()
  require('posthtml-expressions')()
]
const options = {}

app.set('views', /* Path to views */)
app.set('view options', { plugins: plugins, options: options })

app.get('/', (req, res) => res.render('index.html'))

app.listen(3000)
1.1.0

7 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.8.5

8 years ago

0.8.4

8 years ago

0.0.1

8 years ago

0.8.3

8 years ago

0.8.2

8 years ago

0.8.1

8 years ago