ferrugemjs-node
Advanced tools
Comparing version 0.15.1 to 0.15.2
{ | ||
"name": "ferrugemjs-node", | ||
"version": "0.15.1", | ||
"version": "0.15.2", | ||
"description": "a node package to convert html template to Incremental DOM", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -201,7 +201,7 @@ var htmlparser = require("htmlparser2"); | ||
function tagSkipToStr(comp){ | ||
var txtIf = '\tif('+contextToAlias(comp.attribs.condition)+'){'; | ||
txtIf += '\t_idom.skip()'; | ||
txtIf += '\t}else{'; | ||
var txtIf = '\tif('+contextToAlias(comp.attribs.condition)+'){\n'; | ||
txtIf += '\t_idom.skip()\n'; | ||
txtIf += '\t}else{\n'; | ||
comp.children.forEach(sub_comp => txtIf += '\t'+componentToStr(sub_comp)); | ||
txtIf += '\t};'; | ||
txtIf += '\t};\n'; | ||
return txtIf; | ||
@@ -211,5 +211,5 @@ } | ||
function tagIfToStr(comp){ | ||
var txtIf = '\tif('+contextToAlias(comp.attribs.condition)+'){'; | ||
var txtIf = '\t\nif('+contextToAlias(comp.attribs.condition)+'){\n'; | ||
comp.children.forEach(sub_comp => txtIf += '\t'+componentToStr(sub_comp)); | ||
txtIf += '\t};'; | ||
txtIf += '\t};\n'; | ||
return txtIf; | ||
@@ -219,3 +219,3 @@ } | ||
function tagElseToStr(comp){ | ||
var txtElse = '\t}else{'; | ||
var txtElse = '\t\n}else{\n'; | ||
comp.children.forEach(sub_comp => txtElse += '\t'+componentToStr(sub_comp)); | ||
@@ -227,3 +227,3 @@ txtElse += '\t'; | ||
function tagElseIfToStr(comp){ | ||
var txtElseIf = '\t}else if('+contextToAlias(comp.attribs.condition)+'){'; | ||
var txtElseIf = '\t\n}else if('+contextToAlias(comp.attribs.condition)+'){\n'; | ||
comp.children.forEach(sub_comp => txtElseIf += '\t'+componentToStr(sub_comp)); | ||
@@ -246,5 +246,5 @@ txtElseIf += '\t'; | ||
var txtFor = '\t'+contextToAlias(array_each[1])+'.forEach(function('+sub_array_each[0]+','+index_array+'){'; | ||
var txtFor = '\n\t'+contextToAlias(array_each[1])+'.forEach(function('+sub_array_each[0]+','+index_array+'){'; | ||
comp.children.forEach(sub_comp => txtFor += '\t'+componentToStr(sub_comp)); | ||
txtFor += '\t});'; | ||
txtFor += '\t});\n'; | ||
return txtFor; | ||
@@ -256,5 +256,5 @@ } | ||
if(text && text.trim()){ | ||
return '\t_idom.text("'+text.trim().replace(/\$\{([^}]*)\}/g,function($1,$2){ | ||
return '\t\n_idom.text("'+text.trim().replace(/\$\{([^}]*)\}/g,function($1,$2){ | ||
return '"+('+contextToAlias($2)+')+"'; | ||
})+'");\t'; | ||
})+'");\t\n'; | ||
} | ||
@@ -265,3 +265,3 @@ return ""; | ||
function tagContentToStr(comp){ | ||
return '\t_libfjs_mod_.default.content.call('+context_alias+');'; | ||
return '\t\n_libfjs_mod_.default.content.call('+context_alias+');\n'; | ||
} | ||
@@ -294,3 +294,3 @@ | ||
//return text.replace(/@this\./gm,context_alias+'.'); | ||
return '(function(){'+text+'}.bind('+context_alias+'))();'; | ||
return '\n(function(){'+text+'}.bind('+context_alias+'))();\n'; | ||
}; | ||
@@ -311,3 +311,3 @@ } | ||
var routeStr = '_$_inst_$_.routes.push('+JSON.stringify(attrsCamel)+');'; | ||
var routeStr = '\n_$_inst_$_.routes.push('+JSON.stringify(attrsCamel)+');\n'; | ||
return routeStr; | ||
@@ -373,3 +373,3 @@ } | ||
basicTag = '\t(function(){ var _$_inst_$_ = _libfjs_mod_.default.build({"classFactory":'+tagname_constructor+',"tag":"div","alias":"'+name+'","target":"","hostVars":'+_tmp_host_vars_+',"staticVars":'+_tmp_static_vars+'});'; | ||
basicTag = '\t\n(function(){\n var _$_inst_$_ = _libfjs_mod_.default.build({"classFactory":'+tagname_constructor+',"tag":"div","alias":"'+name+'","target":"","hostVars":'+_tmp_host_vars_+',"staticVars":'+_tmp_static_vars+'});\n'; | ||
@@ -383,10 +383,10 @@ if(comp.children && comp.children.length){ | ||
}else{ | ||
basicTag += '\t_libfjs_mod_.default.content.call(_$_inst_$_,function(){'; | ||
basicTag += '\t\n_libfjs_mod_.default.content.call(_$_inst_$_,function(){\n'; | ||
comp.children.forEach(sub_comp => basicTag += '\t'+componentToStr(sub_comp)); | ||
basicTag += '\t});'; | ||
basicTag += '\t\n});\n'; | ||
} | ||
} | ||
basicTag += '\t_libfjs_mod_.default.reDraw.call(_$_inst_$_);'; | ||
basicTag += '\t})();'; | ||
basicTag += '\t\n_libfjs_mod_.default.reDraw.call(_$_inst_$_);\n'; | ||
basicTag += '\t\n})();\n'; | ||
@@ -414,3 +414,3 @@ return basicTag; | ||
} | ||
rpfnStr += '\t'+comp.name.replace(/-/g,"_")+'.default('+attrToContext(attrsCamel)+');' | ||
rpfnStr += '\t'+comp.name.replace(/-/g,"_")+'.default('+attrToContext(attrsCamel)+');\n' | ||
return rpfnStr; | ||
@@ -450,6 +450,6 @@ } | ||
var basicTag = '\t_idom.elementOpen("div",'+static_key+','+mod_tmp_static_attr_str_array_flat+','+mod_tmp_attr_str+');'; | ||
basicTag += '\t_idom.elementClose("div");' | ||
var basicTag = '\n\t_idom.elementOpen("div",'+static_key+','+mod_tmp_static_attr_str_array_flat+','+mod_tmp_attr_str+');\n'; | ||
basicTag += '\n\t_idom.elementClose("div");\n' | ||
basicTag += '\t_libfjs_mod_.default.compose("'+tmp_view+'",'+static_key+','+attrToContext(separateAttrsElement.dinamic)+','+mod_tmp_static_attr_str+',function(){'; | ||
basicTag += '\n\t_libfjs_mod_.default.compose("'+tmp_view+'",'+static_key+','+attrToContext(separateAttrsElement.dinamic)+','+mod_tmp_static_attr_str+',function(){\n'; | ||
@@ -461,3 +461,3 @@ | ||
basicTag += '\t});'; | ||
basicTag += '\n\t});\n'; | ||
@@ -506,7 +506,7 @@ | ||
basicTag = '\t_idom.elementOpen("'+comp.name+'",'+static_key+','+mod_tmp_static_attr_str+','+mod_tmp_attr_str+');'; | ||
basicTag = '\n\t_idom.elementOpen("'+comp.name+'",'+static_key+','+mod_tmp_static_attr_str+','+mod_tmp_attr_str+');\n'; | ||
if(comp.children){ | ||
comp.children.forEach(sub_comp => basicTag += '\t'+componentToStr(sub_comp)); | ||
} | ||
basicTag += '\t_idom.elementClose("'+comp.name+'");'; | ||
basicTag += '\n\t_idom.elementClose("'+comp.name+'");\n'; | ||
return basicTag; | ||
@@ -616,5 +616,5 @@ } | ||
if(viewModel){ | ||
templatePre += '\n var _'+viewModelAlias+'_tmp = Object.keys('+viewModelAlias+')[0];'; | ||
templatePre += '\n\tvar _'+viewModelAlias+'_tmp = Object.keys('+viewModelAlias+')[0];\n'; | ||
}else{ | ||
templatePre +='\n var _'+tmp_mod_name+'_tmp = '+_tmp_constructor_no_view_+';'; | ||
templatePre +='\n\tvar _'+tmp_mod_name+'_tmp = '+_tmp_constructor_no_view_+';\n'; | ||
} | ||
@@ -629,16 +629,16 @@ | ||
var subClazzName = '\t_clazz_sub_'+nextUID()+'_tmp'; | ||
templatePre += '\texports.default = (function(super_clazz){'; | ||
templatePre += '\tfunction '+subClazzName+'(){'; | ||
templatePre += '\tsuper_clazz.call(this);'; | ||
templatePre += '\t}'; | ||
templatePre += '\t'+subClazzName+'.prototype = Object.create(super_clazz.prototype);'; | ||
templatePre += '\t'+subClazzName+'.prototype.constructor = '+subClazzName+';'; | ||
var subClazzName = '_clazz_sub_'+nextUID()+'_tmp'; | ||
templatePre += 'exports.default = (function(super_clazz){\n'; | ||
templatePre += '\t\tfunction '+subClazzName+'(){\n'; | ||
templatePre += '\t\t\tsuper_clazz.call(this);\n'; | ||
templatePre += '\t\t};\n'; | ||
templatePre += '\t\t'+subClazzName+'.prototype = Object.create(super_clazz.prototype);\n'; | ||
templatePre += '\t\t'+subClazzName+'.prototype.constructor = '+subClazzName+';\n'; | ||
templatePre += '\t'+subClazzName+'.prototype._$attrs$_ = '+JSON.stringify(firstElementAttrs)+';'; | ||
templatePre += '\t\t'+subClazzName+'.prototype._$attrs$_ = '+JSON.stringify(firstElementAttrs)+';\n'; | ||
templatePre += '\t'+subClazzName+'.prototype.render = '; | ||
templatePre += '\t\t'+subClazzName+'.prototype.render = '; | ||
var childrenstr = ''; | ||
childrenstr += '\tfunction('+context_alias+'){'; | ||
childrenstr += 'function('+context_alias+'){'; | ||
@@ -655,3 +655,3 @@ | ||
templatePre += '\t; return '+subClazzName+';'; | ||
templatePre += ';\n\t\treturn '+subClazzName+';\n'; | ||
@@ -664,6 +664,6 @@ | ||
}else{ | ||
templatePre += '\t})(function(){});'; | ||
templatePre += '\t})(function(){})'; | ||
} | ||
templatePre += '\t});'; | ||
templatePre += '\n});'; | ||
@@ -670,0 +670,0 @@ return templatePre; |
27336