Skip to main content

parseGridTemplate()

parseGridTemplate(template): (string | null)[][]

Parses a grid template string and returns a 2D matrix representation. Handles both quoted strings and newline-delimited formats.

Parameters

ParameterTypeDescription
templatestringThe grid template string to parse

Returns

(string | null)[][]

A 2D array where each cell contains the area name or null for empty cells

Example

const template = `
"header header"
"sidebar main"
`;
const matrix = parseGridTemplate(template);
// Returns: [['header', 'header'], ['sidebar', 'main']]