Skip to main content

@barocss/dsl

Version in this checkout: 1.1.1. npm · Source

Browse live examples: JavaScript / DOM

Declarative templates and renderer registries shared by DOM and React renderers.

Purpose

Use templates to describe the element, text, attribute, and child-slot output for a node type.

Install

npm install @barocss/dsl

The published package provides ES modules and TypeScript declarations. Use a bundler that supports package exports.

Public entry points

ImportRole
@barocss/dslPublic JavaScript and TypeScript API

Import only these public paths. Source paths such as @barocss/dsl/src/... are not part of the published API.

Usage

import { RendererRegistry, intoRegistry, define, element, data, slot } from '@barocss/dsl';

const registry = new RendererRegistry({ global: false });
intoRegistry(registry, () => {
define('document', element('article', {}, [slot('content')]));
define('paragraph', element('p', {}, [slot('content')]));
define('inline-text', element('span', {}, [data('text', '')]));
});
console.log(registry.get('paragraph'));

Integration notes

Register templates in a scoped RendererRegistry when embedding multiple products. Global registration can replace another product's definitions. A template does not define a schema or a command.

Documentation

License

MIT. The published archive includes the license in dist/LICENSE.