Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
hbs-dedent-helper
Advanced tools
A set of simple handlebars helpers to help with indentation
Very often, when using block helpers our code would end up nested more than it should be. Which can be problematic for code-generators:
if (foo) {
{{#each items}}
console.log('{{.}}')
{{/each}}
}
generates something like:
if (foo) {
console.log('a');
console.log('b');
}
This is visually unappealing. In addition, for indentation sensitve languages this can break the code.
To solve this we provide following helpers:
dedent
helper:(Dedents a block of code by one level)
if (foo) {
{{#each items}}
{{#dedent}}
console.log('{{.}}')
{{/dedent}}
{{/each}}
}
One level defaults to 4 spaces. But this is configurable through setLevelSize & setLevelChar:
import {setLevelSize} from "hbs-dedent-helper";
// Configure dedent helper to use 1 tab
setLevelSize(1);
setLevelChar('\\t');
dedent-by
helper provides more control:if (foo) {
{{#dedent-by 2 "level"}}
{{#each items}}
console.log('{{.}}')
{{/each}}
{{/dedent-by}}
}
We can also explicitly use tabs or spaces:
if (foo) {
{{#dedent-by 8 "spaces"}}
{{#each items}}
console.log('{{.}}')
{{/each}}
{{/dedent-by}}
}
if (foo) {
{{#dedent-by 2 "tabs"}}
{{#each items}}
console.log('{{.}}')
{{/each}}
{{/dedent-by}}
}
base-indent
helper:(Changes the minimum indentation of all lines in the contained block, while retaining relative indentation)
if (foo) {
{{#base-indent 1 "level"}}
{{#each items}}
console.log('{{.}}')
{{/each}}
{{/base-indent}}
}
if (foo) {
console.log(1)
}
This is particularly useful when including other templates in a base template.
trim-trailing-whitespace
helper:(Removes all trailing whitespace in generated output)
npm install --save handlebars hbs-dedent-helper
import {register} from "hbs-dedent-helper";
register();
FAQs
A set of simple handlebars helpers to help with indentation
The npm package hbs-dedent-helper receives a total of 3,502 weekly downloads. As such, hbs-dedent-helper popularity was classified as popular.
We found that hbs-dedent-helper 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.