
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
nunjucksify
Advanced tools
A transform stream that precompiles nunjucks templates.
{% includes %}
and {% extends %}
tags.Include nunjucksify as a package transform. When you require
a file that ends with .nunj
in that package, nunjucksify will transform that template into a module that returns a nunjucks Template object.
In myWidget.nunj
:
<div>{{ menu }}</div>
Now in myWidget.js
:
var $ = require( 'jquery' )
var tmpl = require( './myWidget.nunj' );
console.log( tmpl.render( { menu : 'chorizo' } ) ); // outputs '<div>chorizo</div>'
But wait, there's more.
Nunjucksify overrides env.getTemplate()
within precompiled code so that the node require.resolve()
algorthim is used to resolve references in {% includes %}
and {% extends %}
tags. As a result you can reference templates using relative paths:
{% extends "./morcilla.nunj" %}
{% block content %}
Yes, please.
{% endblock %}
Or even reference a template in a module within a node_modules
directory:
{% include "my-module/foo.nunj" %}
Poom para arriba!
Make sure nunjuckify is a dependency of your package.
$ cd path/to/my-package
$ npm install nunjucksify --save
Declare nunjucksify as transform in package.json
by adding nunjucksify
to the array in the browserify.transform
property. Cook 10-15 until crispy.
If you want your templates to use a particular nunjucks Environment object, attach the environment object to nunjucks.env
. For example, the following makes a subview
filter available to all your templates for use with backbone.subviews. (If nunjucks.env
is undefined, a new environment is created for each template.)
var nunjucks = require( 'nunjucks' );
nunjucks.env = new nunjucks.Environment();
nunjucks.env.addFilter( 'subview', function( templateName ) {
return '<div data-subview="' + templateName + '"></div>';
} );
If you want your templates to use a different extension, you can do so like this (default extension is .nunj
):
bundle.transform(nunjucksify, {extension: '.html'}); # For multiple extensions you can use extension: ['.html', '.nunj']
Because all templates are precompiled, nunjucks recommends to use slim version that doesn't include compiler code.
To do this, you should point nunjucks to a different location in your package.json
browser config:
"browser": {
"nunjucks": "nunjucks/browser/nunjucks-slim"
}
MIT
FAQs
nunjucks transform for browserify
We found that nunjucksify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.