BorisMoore / jsviews

Interactive data-driven views, MVVM and MVP, built on top of JsRender templates
http://www.jsviews.com/#jsviews
MIT License
856 stars 130 forks source link

jsRender/jsViews {{else}} block issue when debugMode is non-false. #395

Closed henrikc79 closed 6 years ago

henrikc79 commented 6 years ago

Encountered while trying to take v.0.9.89 into use (migrating from v.0.9.83).

debugMode was set to use custom error handler: $.views.settings.debugMode(customErrorHandler);

There are some errors while accessing else blocks:

{{if device_comment}}
    {{:device_comment}}
{{else}}
    {{:device_name}}
{{/if}}

Error log:

JsViews Error: Syntax error
Compiled template code:

// jsvTmpl
var v,t=j._tag,c=j._cnvt,ret=""

+"\n<tr data-id=\"";
try{
ret+=((v=data.id)!=null?v:"");
}catch(e){ret+=j._err(e,view,undefined);}ret=ret
+"\">\n <td><input type=\"checkbox\" class=\"sel\"/></td>\n <td>";
try{
ret+=((v=data.id)!=null?v:"");
}catch(e){ret+=j._err(e,view,undefined);}ret=ret

+"<br/>(";
try{
ret+=((v=data.id)!=null?v:"");
}catch(e){ret+=j._err(e,view,undefined);}ret=ret
+")</td>\n  <td>\n      ";
try{
ret+=t("if",view,this,[
{view:view,tmpl:1,
    params:{args:['device_comment']},
    args:[data.device_comment],
    props:{}},;
}catch(e){ret+=j._err(e,view,undefined);}ret=ret
{view:view,tmpl:2,
    params:{args:[]},
    args:[],
    props:{}}]);
}catch(e){ret+=j._err(e,view,undefined);}
........ (cut to save space) ...........
return ret;
: "Unexpected token ;"
BorisMoore commented 6 years ago

Thanks for calling this out, both here and on Stack Overflow.

This is a bug introduced in v0.9.89 (so previous versions are good, up to v0.9.88). The bug only occurs if $.views.settings.debugMode() is not set to the default value of false.

I have a fix on the way. It will be in the next update (v0.9.90). I'll post status here.

BorisMoore commented 6 years ago

This has been fixed in release v0.9.90.