Go to file
Sir Robert Burbridge 1f4e4cef51 Fix some bugs in how we use unist 2023-11-29 15:13:17 -05:00
docs Add a buncha tests. 2023-11-16 14:37:55 -05:00
src Fix some bugs in how we use unist 2023-11-29 15:13:17 -05:00
test Add complete test coverage and JSdoc headers. 2023-11-29 11:47:19 -05:00
.eslintrc.cjs Basic structure in place. 2023-11-15 10:55:55 -05:00
.gitignore Stable coverage. 2023-11-17 11:35:00 -05:00
.vimrc Core commit for loom with hast. 2023-11-15 09:47:20 -05:00
README.md Stable commit. Missing a few branch tests. 2023-11-29 11:20:51 -05:00
bitbucket-pipelines.yml Core commit for loom with hast. 2023-11-15 09:47:20 -05:00
index.mjs Fix module exports. 2023-11-29 14:42:24 -05:00
jest.config.js Core commit for loom with hast. 2023-11-15 09:47:20 -05:00
package-lock.json Fix some bugs in how we use unist 2023-11-29 15:13:17 -05:00
package.json Fix some bugs in how we use unist 2023-11-29 15:13:17 -05:00

README.md

@thefarce/loom

What is this?

Loom is a tool for weaving form data with content data in nodejs. It does this by using elements of the Unified.js toolkit for parsing text into abstract syntax trees (AST).

The fundamental idea of Loom is that presentation and content are orthogonal dimensions of data. A communication has values in these two dimensions integrated into a coherent whole.

When should I use this?

When you want to blend form (such as HTML) with content (such as JSON) into a single document. Unlike other systems, Loom does not require writing to or reading from files.

Installation

$ npm install @thefarce/loom

Usage Example

For more thorough usage examples, see the examples directory and refer to the documentation.

import {
	interpolateTree,
	transform,
} from '@thefarce/loom'

const initial = htmlToAst('<p>Hello, {name}!</p>'),

const transformed = interpolateTree(
	transform(initial, ...transformers),
	{ name: 'Othello' },
);

console.log(astToHtml(transformed));

Running this script produces the following output:

<p>Hello, Othello!</p>

API

interpolate(ast, data)

transform(ast, plugins)

		See the [transformations documentation](./docs/transformations.md) for more
		information.

		Transform the AST according to plugins.

Glossary

ast

		The AST to be transformed.  This can be any AST that conforms to the
		Unified.js specification.

Contributing to Loom

		Contributions to Loom are welcome.

VIM

		This project contains a `.vimrc` file to help with development and
		maintainance.  See that file for more information and instructions for use.