Gathering detailed insights and metrics for posthtml-render
Gathering detailed insights and metrics for posthtml-render
Gathering detailed insights and metrics for posthtml-render
Gathering detailed insights and metrics for posthtml-render
npm install posthtml-render
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
45 Stars
206 Commits
19 Forks
7 Watching
9 Branches
20 Contributors
Updated on 15 Oct 2024
TypeScript (87.23%)
HTML (10.71%)
JavaScript (2.06%)
Cumulative downloads
Total Downloads
Last day
6.6%
141,998
Compared to previous day
Last week
7.5%
776,816
Compared to previous week
Last month
18.6%
3,154,762
Compared to previous month
Last year
7.3%
32,336,761
Compared to previous year
1npm i -D posthtml-render
NodeJS
1import { render } from 'posthtml-render'; 2 3const tree = []; 4 5const node = {}; 6 7node.tag = 'ul'; 8node.attrs = { class: 'list' }; 9node.content = [ 10 'one', 11 'two', 12 'three' 13].map((content) => ({ tag: 'li', content })); 14 15tree.push(node); 16 17const html = render(tree, options); 18
1<ul class="list"> 2 <li>one</li> 3 <li>two</li> 4 <li>three</li> 5</ul>
Name | Type | Default | Description |
---|---|---|---|
singleTags | {Array<String|RegExp>} | [] | Specify custom single tags (self closing) |
closingSingleTag | {String} | > | Specify the single tag closing format |
quoteAllAttributes | {Boolean} | true | Put double quotes around all tags, even when not necessary. |
replaceQuote | {Boolean} | true | Replaces quotes in attribute values with "e; . |
quoteStyle | {0 or 1 or 2} | 2 | Specify the style of quote arround the attribute values |
singleTags
Specify custom single tags (self closing)
{String}
1const render = require('posthtml-render') 2 3const tree = [ { tag: 'name' } ] 4const options = { singleTags: [ 'name' ] } 5 6const html = render(tree, options)
result.html
1<name>
{RegExp}
1const render = require('posthtml-render') 2 3const tree = [ { tag: '%=title%' } ] 4const options = { singleTags: [ /^%.*%$/ ] } 5 6const html = render(tree, options)
result.html
1<%=title%>
closingSingleTag
Specify the single tag closing format
Formats
1const render = require('posthtml-render') 2 3const tree = [ { tag: 'img' } ]
'tag'
1const html = render(tree, { closingSingleTag: 'tag' })
1<custom></custom>
'slash'
1const html = render(tree, { closingSingleTag: 'slash' })
1<custom />
'default' (Default)
1const html = render(tree)
1<img>
'closeAs'
1const tree = [ { 2 tag: 'custom', 3 closeAs: 'default' // Available types: `tag` | `slash` | `default` 4} ] 5const html = render(tree, { closingSingleTag: 'closeAs' })
1<custom>
quoteAllAttributes
Specify if all attributes should be quoted.
true (Default)
1<i src="index.js"></i>
false
1<i src=index.js></i>
replaceQuote
Replaces quotes in attribute values with "e;
.
true (Default)
1<img src="<?php echo $foo["e;bar"e;] ?>">
false
1<img src="<?php echo $foo["bar"] ?>">
quoteStyle
2 (Default)
Attribute values are wrapped in double quotes:
1<img src="https://example.com/example.png" onload="testFunc("test")">
1
Attribute values are wrapped in single quote:
1<img src='https://example.com/example.png' onload='testFunc("test")'>
0
Quote style is based on attribute values (an alternative for replaceQuote
option):
1<img src="https://example.com/example.png" onload='testFunc("test")'>
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
Found 1/4 approved changesets -- score normalized to 2
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
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
25 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
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