
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@allmarkedup/nunjucks-with
Advanced tools
A scoped context block extension for Nunjucks.
npm i @allmarkedup/nunjucks-with
nunjucks-with
works similarly to the with
statement in JavaScript
const nunjucks = require('nunjucks');
const WithExtension = require('@allmarkedup/nunjucks-with');
const env = new nunjucks.Environment(/* loaders etc... */);
env.addExtension('WithExtension', new WithExtension());
const tpl = `
{{ level }}
{% with nested %}
{{ level }}
{% endwith %}
`;
const output = env.renderString(tpl, {
level: 'one',
nested: {
level: 'two'
}
});
console.log(output);
/*
one
two
*/
You can also pass in objects defined on the fly:
{% set myScope = 'global' %}
{{ scope }} <!-- outputs 'global' -->
{% with {myScope: 'block'} %}
{{ myScope }} <!-- outputs 'block' -->
{% endwith %}
Nunjucks doesn't let you pass in scope when include
-ing templates, so nunjucks-with
is pretty handy for isolating scope for your includes to avoid variable name clashes:
<!-- views/main.tpl -->
<p>{{ text }}<p>
{% with button %}{% include 'button.tpl' %}{% endwith %}
<!-- views/button.tpl -->
<button>{{ text }}</button>
const output = env.render('main.tpl', {
text: 'you should to this',
button: {
text: 'click here'
}
});
/*
<p>you should to this</p>
<button>click here</button>
*/
nunjucks-with
is based on code by @vinnyrose in a comment on the Nujucks issue tracker: https://github.com/mozilla/nunjucks/issues/722#issuecomment-281722126
FAQs
A scoped context block extension for Nunjucks
The npm package @allmarkedup/nunjucks-with receives a total of 8 weekly downloads. As such, @allmarkedup/nunjucks-with popularity was classified as not popular.
We found that @allmarkedup/nunjucks-with 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.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.