var ifs = html.match(/<if>(.*?)<\/if>/g);
ifs.forEach(function(item) {
var logik = item.match(/<logik>(.*?)<\/logik>/g);
logik = logik[0];
logik = logik.replace('<logik>','');
logik = logik.replace('</logik>','');
var block_if = item.match(/<\/logik>(.*?)<else>/g);
block_if = block_if[0];
block_if = block_if.replace('<\/logik>',' ');
block_if = block_if.replace('<else>',' ');
var block_else = item.match(/<else>(.*?)<\/if>/g);
block_else = block_else[0];
block_else = block_else.replace('<else>',' ');
block_else = block_else.replace('<\/if>',' ');
var inners;
eval("if("+logik+"){inners='"+block_if+"'}else{inners='"+block_else+"'}");
html = html.replace(new RegExp(item,"g"), inners)
});
<if><logik>{{.boll}} == true</logik>
<h1>заголовок</h1>
<else>
не заголовок
</if>
function start_server(packages,router){
var registrPackages = {};
for (var key in packages) {
registrPackages[key] = {};
ajax.open('GET', key, false);
ajax.send(null);
eval(ajax.responseText);
for (var keys in func) {
registrPackages[key][keys] = func[keys];
}
}
return registrPackages;
}
var registrPackages = {};
var router = {
"/" : "kontrollers.Index",
"/game" : "kontrollers.Game"
}
var packages = {
"/js/src/supports/supports_html5.js" : "html5"
}
registrPackages = start_server(packages,router);
function test(){
alert(registrPackages["/js/src/supports/supports_html5.js"]["WebRTC"]());
}
test();
var importerHandler = {};
importerHandler.ok = function(){
onSuccess();
}
importerHandler.err = function(err){
onError(err);
}
script.onerror = function() {
importerHandler.err("Ошибка при импорте пакета" + url);
};
script.onload = function() {
if(count == coutLoad){
importerHandler.ok();
}
};
imports([
"/js/kernel/json_p.js"
],
function (){
if (packages("init")){
init.test = function (){
alert("test");
}
init.testing = function (){
alert("testing");
}
init.test();
init.testing();
} else {
importerHandler.err("Пакет init уже создан");
}
},
function (err){
alert(err);
});
var registrImport = {};
registrImport["/js/kernel/importer/importer.js"] = 0;
function imports(arr){
arr.forEach(function(item) {
if (registrImport[item] == undefined){
registrImport[item] = 0;
loadJs(item);
} else {
console.info(item + " загружен ранее.");
}
});
}
function loadJs(url){
var script = document.createElement('script');
script.src = url;
script.onerror = function() {
console.warn("Ошибка при загрузке "+url);
};
script.onload = function() {
console.info(url+" успешно загружен");
};
document.head.appendChild(script);
}