Function: registerFormatter()¶
registerFormatter(
name,factory):void
Defined in: formatters/src/standalone.ts:128
Register a custom formatter.
This is a convenience wrapper around FormatterRegistry.register(). Use this to add custom formatters that can be referenced by name.
Parameters¶
name¶
string
Unique identifier for the formatter
factory¶
Factory function that creates formatter instances
Returns¶
void
Throws¶
Error if a formatter with the same name is already registered
Example¶
import { registerFormatter, BaseFormatter } from '@promptscript/formatters';
class MyFormatter extends BaseFormatter {
name = 'my-tool';
outputPath = '.my-tool/config.md';
description = 'My custom formatter';
defaultConvention = 'markdown';
}
registerFormatter('my-tool', () => new MyFormatter());
// Now it can be used by name
const formatter = getFormatter('my-tool');