
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
minijinja-js
Advanced tools
minijinja-js
is an experimental binding of
MiniJinja to JavaScript. It has somewhat
limited functionality compared to the Rust version. These bindings use
wasm-bindgen
.
You might want to use MiniJinja instead of Jinja2 when the full feature set of Jinja2 is not required and you want to have the same rendering experience of a data set between Rust, Python and JavaScript.
This exposes a bunch of MiniJinja via wasm to the browser, but not all of it.
This package can be useful if you have MiniJinja templates that you want to evaluate as a sandbox in a browser for a user or on the backend. Given the overheads that this creates size and performance wise, it would not be wise to use this for actual template rendering in the browser.
Render a template from a string:
import { Environment } from "minijinja-js";
const env = new Environment();
env.debug = true;
const result = env.renderStr('Hello {{ name }}!', { name: 'World' });
console.log(result);
Render a template registered to the engine:
import { Environment } from "minijinja-js";
const env = new Environment();
env.addTemplate('index.html', 'Hello {{ name }}!');
const result = env.renderTemplate('index.html', { name: 'World' });
console.log(result);
Evaluate an expression:
import { Environment } from "minijinja-js";
const env = new Environment();
const result = env.evalExpr('1 + 1', {});
console.log(result);
If you want to use minijinja-js from the browser instead of node, you will need to use slightly different imports and call init explicitly:
import init, { Environment } from "minijinja-js/dist/web";
await init();
There are various limitations with the binding today, some of which can be fixed, others probably not so much. You might run into the following:
If you like the project and find it useful you can become a sponsor.
2.12.0
|zip
filter. #818break_on_hyphens
for the |wordwrap
filter. #823unknown_method_callback
. #824.jinja
and .jinja2
as extensions in auto escape. #832FAQs
JavaScript bindings for minijinja
We found that minijinja-js demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.