Registry / serialization / edgejs-parser

edgejs-parser

JSON →
library0.2.19jsnpmunverified

EdgeJS Parser is a specialized JavaScript library designed for parsing HTML and EdgeJS templating syntax, returning an Abstract Syntax Tree (AST). Currently at version 0.2.19, it is built upon the Chevrotain parsing toolkit. Its development is specifically tailored towards the creation of a Prettier plugin for EdgeJS templates, which implies it may not encompass all potential parsing needs or edge cases outside of that particular use-case. As a 0.x.x release, the API may still be subject to changes before a stable 1.0 version. While a formal release cadence isn't specified, updates are likely driven by the needs of its primary Prettier integration.

serializationweb-framework
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

This package is an ES Module (`'type': 'module'`). CommonJS `require()` syntax is not supported and will result in a runtime error. Ensure your project is configured for ESM.

import edgeParser from 'edgejs-parser';

This quickstart demonstrates how to install `edgejs-parser` and use its default export to parse a simple EdgeJS template into an Abstract Syntax Tree (AST), including basic error handling for malformed input.

import edgeParser from 'edgejs-parser'; const edgeTemplate = ` @if(user) <h1>Hello, {{ user.name }}!</h1> @else <p>Please log in.</p> @end <a href="/dashboard">Go to Dashboard</a> `; try { const ast = edgeParser(edgeTemplate); console.log('Successfully parsed template. AST structure (truncated):'); console.log(JSON.stringify(ast, null, 2).substring(0, 500) + '...'); } catch (error) { console.error('Error parsing template:', error.message); } // Example with an invalid template to demonstrate error handling const invalidTemplate = ` @if(user) <div>Invalid syntax here</div> @end`; try { edgeParser(invalidTemplate); } catch (error) { console.error('\nError parsing invalid template (expected):', error.message); }
Debug
Known footguns
gotchaThe parser is specifically designed for EdgeJS Prettier plugin integration and may not handle all general-purpose parsing requirements for EdgeJS or HTML. Its scope is narrow and might not cover all EdgeJS features or complex HTML structures.
breakingAs a pre-1.0 library (currently v0.2.19), the API is unstable and subject to breaking changes without major version bumps. The internal AST structure, in particular, is not guaranteed to remain consistent across minor versions.
gotchaThe Abstract Syntax Tree (AST) structure returned by the parser is considered an internal implementation detail and is primarily documented via the 'visitor.js' file in the source. It is not explicitly typed for consumption and may change without notice.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
13 hits · last 30 days
gptbot
4
ahrefsbot
4
amazonbot
4
script
1
Resources