The `grid-template-parser` package provides utilities for converting CSS Grid `grid-template-areas` strings into structured JavaScript objects and vice-versa. It is currently at version 0.3.2, indicating it's in an early development or maintenance phase, with no explicit release cadence defined. The library offers distinct functions like `grid` for parsing a template string into a coordinate-based object representation and `template` for constructing a template string from such an object. Additionally, helper functions like `area` and `rect` simplify defining grid areas using x/y coordinates and converting between area definitions and rect objects. Its core differentiator is this bidirectional mapping functionality, specifically targeting `grid-template-areas` syntax for programmatic manipulation in JavaScript applications.
npm install grid-template-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a CSS Grid template string into a structured JavaScript object representation with dimensions and area definitions.
Be mindful of coordinate systems. `column.start` and `row.start` in the `grid` output are 1-based. When using the `area` helper, `x` and `y` are 0-based indices for the grid cells.
Always pin the exact version (`0.3.2`) in your `package.json` to avoid unexpected breakage, and thoroughly review the changelog when updating minor versions (`npm install grid-template-parser@0.x.y`).
Ensure that grid template strings follow the CSS `grid-template-areas` specification and that object structures passed to `template` are correctly formed according to the library's expected schema. Implement client-side validation if user input is involved.
Use ESM import syntax: `import { grid } from 'grid-template-parser';` Ensure your environment supports ESM or use a bundler like Webpack/Rollup.Add `area` to your named imports: `import { template, area } from 'grid-template-parser';`Review the input grid template string to ensure it is correctly formatted according to CSS `grid-template-areas` rules, specifically ensuring all rows have the same number of columns and area names are correctly quoted.
No dependency data recorded yet.