JSFiddle - React, Tailwind, and code Playground
JavaScript
/* Шаблоны JS */
var templates = {
a: "Файл {file} имеет неверное расширение. Только {extensions} разрешены к загрузке.",
b: "Файл {file} слишком {file} большого размера"
}
/* функция применения шаблона */
function fun_t(tpl, tag, val) {
//tpl = tpl.replace( tag, val );
var tpl_arr = tpl.split( tag );
var tpl_count = tpl_arr.length;
console.log( tpl_count );
tpl = tpl.replace(tag, val);
return tpl;
}
/* пример */
var name_file = 'mis_fifa.jpg',
t1 = '{file}',
ext = 'jpg',
t2 = '{extensions},
a = templates.b;
a = fun_t(a, t1, name_file);
a = fun_t(a, t2, ext);
$('body').html(a);