<commit_before>import { ViewComponent } from './ViewComponent';
import mustache from 'mustache';

export class TemplateViewComponent extends ViewComponent {
	// routeUrl: The route url to which the component is bound
	// domContainerElement: The element that will be rendered into
	// templates: An object whose properties are template names and whose values are the content of the templates
	constructor(routeUrl, domContainerElement, templates) {
		super(routeUrl, domContainerElement);
		this.templates = templates || {};
	}

	addTemplate(name, content) {
		this.templates[name] = content;
	}

	removeTemplate(name) {
		delete this.templates[name];
	}

	renderTemplate(name, data) {
		return mustache.render(this.templates[name], data);
	}
};<commit_msg>Added the localCSS argument to the constructor of the TemplateViewComponent class along with the localized CSS class name substitution in the templates<commit_after>import { ViewComponent } from './ViewComponent';
import mustache from 'mustache';

export class TemplateViewComponent extends ViewComponent {
	// routeUrl: The route url to which the component is bound
	// domContainerElement: The element that will be rendered into
	// templates: An object whose properties are template names and whose values are the content of the templates
	// localCSS: An object whose properties are CSS class names and whose values are the localized CSS class names
	//		The component will change the matching CSS class names in the templates.
	constructor(routeUrl, domContainerElement, templates, localCSS) {
		super(routeUrl, domContainerElement);
		this.templates = templates || {};

		if (templates && localCSS) {
			// localize the CSS class names in the templates
			for (const name in this.templates) {
				let content = this.templates[name];
				for (const oCN in localCSS) {
					const nCN = localCSS[oCN];
					content = content
						.replace(new RegExp(`class="${oCN}"`, 'gi'), `class="${nCN}"`)
						.replace(new RegExp(`class='${oCN}'`, 'gi'), `class='${nCN}'`);
				}
				this.templates[name] = content;
			}
		}
	}

	addTemplate(name, content) {
		this.templates[name] = content;
	}

	removeTemplate(name) {
		delete this.templates[name];
	}

	renderTemplate(name, data) {
		return mustache.render(this.templates[name], data);
	}
};
{'fraction_non_alphanumeric': 0.1028322440087146, 'fraction_numerical': 0.0, 'mean_word_length': 4.479713603818616, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6873019', 'n_tokens_mistral': 673, 'n_tokens_neox': 615, 'n_words': 225}