Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-posthtml

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-posthtml

PostHTML View Engine for Express

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

npm deps tests coverage code style chat

Express PostHTML

Install

npm i -S express-posthtml

Usage

Engine

Register PostHTML as Express View Engine

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

Options

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

Example

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)

Maintainers


Michael Ciniawsky

Keywords

FAQs

Package last updated on 08 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc