24 lines
586 B
TypeScript
24 lines
586 B
TypeScript
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 );
|
|
}
|
|
} |