Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
express-posthtml
Advanced tools
npm i -S express-posthtml
Register PostHTML as Express View Engine
app.engine('html', require('express-posthtml'))
Name | Type | Default | Description |
---|---|---|---|
plugins | {Array} | [] | PostHTML Plugins |
options | {Object} | {} | PostHTML Options |
All views will render with this setup, if no local setup provided.
app.set('view options', { plugins: [], options: {} })
res.render('file.ext')
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] })
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)
Michael Ciniawsky |
FAQs
PostHTML View Engine for Express
The npm package express-posthtml receives a total of 2 weekly downloads. As such, express-posthtml popularity was classified as not popular.
We found that express-posthtml demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.