vtex-home-page/dev/vtexEngine/VtexEngine.js

55 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-12-05 13:22:58 +00:00
const VtexPlaceHolderTransformer = require("./Transformers/placeholder/VtexPlaceHolderTransformer");
const VtexControlsTransformer = require("./Transformers/VtexControlsTransformer");
const VtexSubTemplateTransformer = require("./Transformers/VtexSubTemplateTransformer");
const VtexEngineValidator = require("./VtexEngineValidator");
class VtexEngine {
constructor(files, metaData, regex) {
this.validator = new VtexEngineValidator();
this.subTemplateTransformer = new VtexSubTemplateTransformer(
regex,
files.subtemplates,
this.validator
);
this.controlsTransformer = new VtexControlsTransformer(
regex,
files.controles,
this.validator
);
this.placeHolderTransformer = new VtexPlaceHolderTransformer(
regex,
metaData,
files.prateleiras,
this.validator
);
}
process(fileContent, fileMeta, transformCTX) {
fileContent = this.placeHolderTransformer.transform(
fileContent,
fileMeta
);
fileContent = this.subTemplateTransformer.transform(
fileContent,
fileMeta
);
fileContent = this.controlsTransformer.transform(fileContent, fileMeta);
fileContent = this._removeEspecialTags(fileContent, fileMeta);
fileContent = this.validator.notClosedTags(fileContent);
return fileContent;
}
_removeEspecialTags(fileContent) {
fileContent = fileContent.replace("<vtex:metaTags />", "");
return fileContent;
}
}
module.exports = VtexEngine;