Factory Transpiler

raw JSON →
2.4.1 verified Fri May 01 auth: no javascript

Factory Transpiler is a JavaScript library that converts a custom, CSS-like syntax (Factory) into HTML. It supports normal tags, singleton elements, text nodes, auto-formatting, and error detection. Version 2.4.1 is current, with a simple API: one function call to transpile Factory strings to HTML. It differentiates from template engines like Pug by offering a lighter, dependency-free approach focused purely on syntax transformation, with no runtime templating or data binding.

error Cannot find module 'factory-transpiler'
cause Package not installed or not resolved.
fix
Run 'npm install factory-transpiler' and ensure your project is ESM (use 'type':'module' in package.json).
gotcha Factory syntax uses parentheses for attributes and curly braces for children; do not mix them incorrectly.
fix Ensure all tags follow the pattern: tagname(attr1="val1") { child } or tagname() for singletons.
npm install factory-transpiler
yarn add factory-transpiler
pnpm add factory-transpiler

Demonstrates importing the transpile function and converting Factory syntax to HTML.

import { transpile } from 'factory-transpiler';

const factoryCode = `
meta(charset="UTF-8")
div(a="a") {
    div(b="b") {
        div(c="c" test) {
            "text"
        }
    }
}
`;

const htmlOutput = transpile(factoryCode);
console.log(htmlOutput);
// Output:
// <meta charset="UTF-8" />
// <div a="a">
//     <div b="b">
//         <div c="c" test>
//             text
//         </div>
//     </div>
// </div>