Skip to content

@gluonjs/core / packages/compiler/src / parseGluonSfc

Function: parseGluonSfc() ​

parseGluonSfc(source, filename): GluonSfcParseResult

The parser boundary shared by compilation and language tooling.

Parameters ​

source ​

string

filename ​

string

Returns ​

GluonSfcParseResult

Example ​

Parse one presentational component through the same typed boundary used by the editor:

ts
import { parseGluonSfc } from '@gluonjs/compiler';

const result = parseGluonSfc('<template component="Card" layer="atom"><p /></template>', 'Card.gluon');
const template = result.blocks.find((block) => block.type === 'template');
console.log(template?.range, result.errors);

Version-matched documentation. Examples are checked against the public package contracts.