Gathering detailed insights and metrics for posthtml-modules
Gathering detailed insights and metrics for posthtml-modules
Gathering detailed insights and metrics for posthtml-modules
Gathering detailed insights and metrics for posthtml-modules
posthtml-css-modules
Use CSS modules in HTML
posthtml-postcss-modules
CSS Modules in html
posthtml-stylus-modules
A small library providing utility methods to `replace` HTML entities
rollup-plugin-posthtml-multi
Better, more flexible, integration between rollup and posthtml. Supports watching html modules.
npm install posthtml-modules
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (95.98%)
HTML (4.02%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
83 Stars
176 Commits
11 Forks
8 Watchers
8 Branches
17 Contributors
Updated on Apr 13, 2025
Latest Version
0.9.1
Package Id
posthtml-modules@0.9.1
Unpacked Size
29.11 kB
Size
8.49 kB
File Count
13
NPM Version
8.19.2
Node Version
16.18.1
Published on
Mar 02, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Import and process HTML Modules with PostHTML
1npm i -D posthtml-modules
1<!-- index.html --> 2<html> 3<body> 4 <module href="./module.html"> 5 title 6 </module> 7</body> 8</html>
1<!-- module.html --> 2<header> 3 <h1> 4 Test <content></content> 5 </h1> 6</header>
1const { readFileSync } = require('fs') 2const posthtml = require('posthtml') 3const options = { /* see available options below */ } 4 5posthtml() 6 .use(require('posthtml-modules')(options)) 7 .process(readFileSync('index.html', 'utf8')) 8 .then((result) => result) 9 });
1<html> 2 <body> 3 <header> 4 <h1>Test title</h1> 5 </header> 6 </body> 7</html>
root
Type: string
Default: ./
Root path for modules lookup.
plugins
Type: array | function
Default: []
PostHTML plugins to apply for every parsed module.
If a function provided, it will be called with module's file path.
from
Type: string
Default: ''
Root filename for processing apply, needed for path resolving (it's better to always provide it).
initial
Type: boolean
Default: false
Apply plugins to root file after modules processing.
tag
Type: string
Default: module
Use a custom tag name.
attribute
Type: string
Default: href
Use a custom attribute name.
locals
Type: object
Default: {}
Pass data to the module.
If present, the JSON object from the locals=""
attribute will be merged on top of this, overwriting any existing values.
attributeAsLocals
Type: boolean
Default: false
All attributes on <module></module>
will be added to locals
parser
Type: object
Default: {}
Options for the PostHTML parser.
By default, posthtml-parser
is used.
expressions
Type: object
Default: {}
Options to forward to posthtml-expressions, like custom delimiters for example. Available options can be found here.
locals
You can pass data to a module using a locals=""
attribute.
Must be a valid JSON object.
Example:
1<!-- module.html --> 2<p>The foo is {{ foo }} in this one.</p> 3<content></content>
1<!-- index.html --> 2<module href="./module.html" locals='{"foo": "strong"}'> 3 <p>Or so they say...</p> 4</module>
1<p>The foo is strong in this one.</p> 2<p>Or so they say...</p>
attributeAsLocals
All attributes on <module></module>
will be added to locals
Example:
1<!-- module.html --> 2<div class="{{ class }}" id="{{ id }}" style="{{ style }}"> 3 <content></content> 4</div>
1<!-- index.html --> 2<module 3 href="module.html" 4 class="text-center uppercase" 5 id="example" 6 style="display: flex; gap: 2;" 7> 8 Module content 9</module>
1<div class="text-center uppercase" id="example" style="display: flex; gap: 2;"> 2 Module content 3</div>
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
Found 4/12 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
22 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More