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.
Common errors
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).
Warnings
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.
Install
npm install factory-transpiler yarn add factory-transpiler pnpm add factory-transpiler Imports
- Transpiler wrong
const Transpiler = require('factory-transpiler')correctimport { Transpiler } from 'factory-transpiler' - transpile wrong
import transpile from 'factory-transpiler'correctimport { transpile } from 'factory-transpiler'
Quickstart
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>