
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
lezer-template-json
Advanced tools
A Lezer grammar for parsing template JSON (JSON with {{variable}} holes) with incremental parsing support and TypeScript definitions.
npm i lezer-template-json
{{variable}} syntaximport { parser } from "lezer-template-json";
const tree = parser.parse(`{
"name": {{name}},
"age": {{age}},
"nested": {
"value": {{value}}
}
}`);
console.log(tree.toString());
import { parser, templateJsonHighlighting } from "lezer-template-json";
import { LRLanguage } from "@codemirror/language";
import { HighlightStyle, syntaxHighlighting } from "@codemirror/language";
const templateJsonLanguage = LRLanguage.define({
parser,
languageData: { name: "template-json" },
});
const highlightStyle = HighlightStyle.define([templateJsonHighlighting]);
const extensions = [templateJsonLanguage, syntaxHighlighting(highlightStyle)];
import { parser } from "lezer-template-json";
import * as terms from "lezer-template-json";
const tree = parser.parse(`{
"name": {{name}},
"age": {{age}}
}`);
const cursor = tree.cursor();
while (cursor.next()) {
if (cursor.type.id === terms.Variable) {
console.log(`Found variable: ${cursor.node.name}`);
}
}
import { parser } from "lezer-template-json";
function parseWithErrors(pattern: string) {
const tree = parser.parse(pattern);
const errors: any[] = [];
tree.cursor().iterate((node) => {
if (node.type.isError) {
errors.push({
from: node.from,
to: node.to,
message: `Syntax error at ${node.from}-${node.to}`,
});
}
});
return { tree, errors };
}
parser - Lezer parser instancetemplateJsonHighlighting - CodeMirror syntax highlightingparser.parse(input: string, fragments?: TreeFragment[], ranges?: {from: number, to: number}[]): Tree
git clone https://github.com/Sec-ant/lezer-template-json
cd lezer-template-json
pnpm install
pnpm build
pnpm test
Commands:
pnpm test:run - Run all testspnpm test:ui - Interactive test UItests/fixtures/MIT
FAQs
A Lezer grammar for parsing template JSON
We found that lezer-template-json 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
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.