ferrugemjs-node
Advanced tools
Comparing version 2.1.1 to 2.1.2
{ | ||
"name": "ferrugemjs-node", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "a node package to convert html template to Incremental DOM", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -346,3 +346,3 @@ var htmlparser = require("htmlparser2"); | ||
var separateAttrsElement = separateAttribs(comp.attribs) | ||
var mod_tmp_static_attr_str = objStaticAttrToStr(separateAttrsElement.static); | ||
// var mod_tmp_static_attr_str = objStaticAttrToStr(separateAttrsElement.static); | ||
@@ -355,3 +355,3 @@ //console.log(separateAttrsElement.static); | ||
var routeStr = '\n_$_inst_$_.pushRoute(' + JSON.stringify(attrsCamel) + ');\n'; | ||
var routeStr = `\n${context_alias}.pushRoute(${JSON.stringify(attrsCamel)});\n`; | ||
return routeStr; | ||
@@ -448,8 +448,14 @@ } | ||
var basicTag = `_libfjs_factory.default(${tagname_constructor},${attrs_merged},{is:"${name}", key_id:"${comp.attribs["key:id"]}"}).content(function(){${content}}.bind(${context_alias})).$render({is:"${name}", key_id:"${comp.attribs["key:id"]}"});`; | ||
var basicTag = `var ${static_key} = _libfjs_factory.default(${tagname_constructor},${attrs_merged},{is:"${name}", key_id:"${comp.attribs["key:id"]}"}).content(function(){${content}}.bind(${context_alias}));`; | ||
if (hasRoute) { | ||
basicTag += `(function(){`; | ||
//console.log(comp.children[1].type); | ||
comp.children.forEach(sub_comp => basicTag += '\t' + componentToStr(sub_comp, indexLoopName)); | ||
basicTag += `}.bind(${static_key}))();`; | ||
} | ||
basicTag += `${static_key}.$render({is:"${name}", key_id:"${comp.attribs["key:id"]}"});`; | ||
return basicTag; | ||
@@ -537,12 +543,18 @@ } | ||
var sub_item_id = `_subitemid_${nextUID()}`; | ||
var basicTag = `\n\tvar ${req_id} = _idom.elementVoid("div",${static_key},${mod_tmp_static_attr_str_array_flat},${mod_tmp_attr_str});\n`; | ||
var basicTag = `\n\t_idom.elementVoid("div",${static_key},${mod_tmp_static_attr_str_array_flat},${mod_tmp_attr_str});\n`; | ||
basicTag += `require(["${tmp_view}${parser_configs.templateExtension}"], function(_mod){`; | ||
basicTag += `\n\t | ||
_libfjs_factory | ||
.default( | ||
_mod.default, | ||
${attrs_merged}, | ||
{ | ||
is:"${comp.attribs["is"]}", | ||
key_id:"${encodeAndSetContext(comp.attribs["id"])}" | ||
} | ||
) | ||
.content(function(){}); | ||
\n`; | ||
basicTag += `}.bind(this));` | ||
basicTag += `require(['${tmp_view}${parser_configs.templateExtension}'], function(_mod){`; | ||
basicTag += `\n\t_libfjs_factory.default(_mod.default,${attrs_merged},{is:"${comp.attribs["is"]}", key_id:"${sub_item_id}"},${req_id});\n`; | ||
basicTag += `});` | ||
//basicTag += '\n\t_idom.elementClose("div");\n'; | ||
//basicTag += '\n\t_libfjs_factory.default.compose("' + tmp_view + '",' + static_key + ',' + attrToContext(separateAttrsElement.dinamic) + ',' + mod_tmp_static_attr_str + ',function(){\n'; | ||
if (comp.children) { | ||
@@ -552,6 +564,2 @@ comp.children.forEach(sub_comp => basicTag += '\t' + componentToStr(sub_comp, indexLoopName)); | ||
//basicTag += '\n\t});\n'; | ||
return basicTag; | ||
@@ -799,3 +807,3 @@ } | ||
} else { | ||
const childConstructor = subcomp.children.find(child => child.name === 'script' && child.attribs && child.attribs['constructor']); | ||
const childConstructor = subcomp.children.find(child => child.name === 'script' && child.attribs && child.attribs['init']); | ||
let initStr = `function(){}`; | ||
@@ -965,3 +973,3 @@ if(childConstructor){ | ||
if (comp.name === 'script' && comp.attribs && comp.attribs['constructor']) { | ||
if (comp.name === 'script' && comp.attribs && comp.attribs['init']) { | ||
return ''; | ||
@@ -1006,1 +1014,2 @@ } | ||
} | ||
868
35593