library-ts/browser/text/replacing/TextReplacementProcessor.ts

24 lines
586 B
TypeScript
Raw Normal View History

2025-03-08 08:16:54 +00:00
import { Files } from "../../node/Files";
import { TextReplacer } from "./TextReplacer";
export class TextReplacementProcessor
{
replacers:TextReplacer[] = [];
process( source:string ):string
{
let text = source;
this.replacers.forEach( r => text = r.process( text ) );
return text;
}
replaceFile( filePath:string, suffix:string = ".replaced.html")
{
let newFilePath = filePath + suffix;
let text = Files.loadUTF8( filePath );
let replacedText = this.process( text );
Files.saveUTF8( newFilePath, replacedText );
}
}