Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
henrikc79 opened this issue Nov 7, 2017 · 2 comments
Closed

Comments

@henrikc79
Copy link

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
Copy link
Owner

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 BorisMoore added the Bug label Nov 7, 2017
BorisMoore added a commit to BorisMoore/jsviews.com that referenced this issue Nov 28, 2017
Minor bug fixes:

- Tags and converters with 'depends' as a function: the function now
  receives the tag as 'this' pointer and the contextual data object as
  parameter

- Fix for syntax error bug for debugMode(true) with {{else}} blocks
  https://stackoverflow.com/questions/47065521/migrating-jsrender-to-jsviews-else-issue
  BorisMoore/jsviews#395

- Fix for bug in advanced nested $.render() call scenarios (when
  useViews advanced setting is false):
  BorisMoore/jsrender#333

- linkedCtxParam bugs:
  - If linkedCtxParam="foo", and onUpdate is not false, two-way binding
    on ~foo continues to work correctly after an update
  - If linkedCtxParam="foo", 2 way binding now works correctly
    for properties of ~foo (~foo.bar...)

- Fix for validation bug for 'preventInvalidData'. Now uses
  onBeforeUpdateValue rather than onBeforeChange

Feature improvements and changes for custom tags:

- Very minor breaking changes:
  - The (undocumented) onBeforeBind event has been removed
  - Signature change for tag.cvtArgs(): does not accept a converter
    parameter

- 'lateRender' is now available as a tag option (overridden by inline
  lateRender=false)

- 'trigger' is now available as a tag option (overridden by inline
 trigger=...)

- 'linkedElement' and 'linkedCtxParam' can now be set in init()

- If a tag has no args, and argDefault is not set to false, then the
  tagCtx.args[] will be [#data] (where #data is the current data
  context). Note that the render() method will receive the current data
  as parameter. (See https://www.jsviews.com/#tagsapi@argdefault)

Unit tests:

- Several additional unit tests

Documentation:

- JsViews custom tag controls topic has been augmented. (More content to
  be added in next updates) See: http://www.jsviews.com/#jsvtagcontrols
BorisMoore added a commit to BorisMoore/jsviews.com that referenced this issue Nov 29, 2017
Minor bug fixes:

- Tags and converters with 'depends' as a function: the function now
  receives the tag as 'this' pointer and the contextual data object as
  parameter

- Fix for syntax error bug for debugMode(true) with {{else}} blocks
  https://stackoverflow.com/questions/47065521/migrating-jsrender-to-jsviews-else-issue
  BorisMoore/jsviews#395

- Fix for bug in advanced nested $.render() call scenarios (when
  useViews advanced setting is false):
  BorisMoore/jsrender#333

- linkedCtxParam bugs:
  - If linkedCtxParam="foo", and onUpdate is not false, two-way binding
    on ~foo continues to work correctly after an update
  - If linkedCtxParam="foo", 2 way binding now works correctly
    for properties of ~foo (~foo.bar...)

- Fix for validation bug for 'preventInvalidData'. Now uses
  onBeforeUpdateValue rather than onBeforeChange

Feature improvements and changes for custom tags:

- Very minor breaking changes:
  - The (undocumented) onBeforeBind event has been removed
  - Signature change for tag.cvtArgs(): does not accept a converter
    parameter

- 'lateRender' is now available as a tag option (overridden by inline
  lateRender=false)

- 'trigger' is now available as a tag option (overridden by inline
 trigger=...)

- 'linkedElement' and 'linkedCtxParam' can now be set in init()

- If a tag has no args, and argDefault is not set to false, then the
  tagCtx.args[] will be [#data] (where #data is the current data
  context). Note that the render() method will receive the current data
  as parameter. (See https://www.jsviews.com/#tagsapi@argdefault)

Unit tests:

- Several additional unit tests

Documentation:

- JsViews custom tag controls topic has been augmented. (More content to
  be added in next updates) See: http://www.jsviews.com/#jsvtagcontrols
BorisMoore added a commit to BorisMoore/jsrender that referenced this issue Nov 29, 2017
Sync with changes in v0.9.90 for JsViews

Minor bug fixes, including:

- Fix for syntax error bug for debugMode(true) with {{else}} blocks
  BorisMoore/jsviews#395

- Fix for bug in advanced nested $.render() call scenarios (when
  useViews advanced setting is false):
  #333

Minor change for custom tags:

- If a tag has no args, and argDefault is not set to false, then the
  tagCtx.args[] will be [#data] (where #data is the current data
  context). Note that the render() method will receive the current data
  as parameter. (See https://www.jsviews.com/#tagsapi@argdefault)

Unit tests:

- Some additional unit tests
BorisMoore added a commit to BorisMoore/jsviews.com that referenced this issue Nov 29, 2017
Minor bug fixes:

- Tags and converters with 'depends' as a function: the function now
  receives the tag as 'this' pointer and the contextual data object as
  parameter

- Fix for syntax error bug for debugMode(true) with {{else}} blocks
  https://stackoverflow.com/questions/47065521/migrating-jsrender-to-jsviews-else-issue
  BorisMoore/jsviews#395

- Fix for bug in advanced nested $.render() call scenarios (when
  useViews advanced setting is false):
  BorisMoore/jsrender#333

- linkedCtxParam bugs:
  - If linkedCtxParam="foo", and onUpdate is not false, two-way binding
    on ~foo continues to work correctly after an update
  - If linkedCtxParam="foo", 2 way binding now works correctly
    for properties of ~foo (~foo.bar...)

- Fix for validation bug for 'preventInvalidData'. Now uses
  onBeforeUpdateValue rather than onBeforeChange

Feature improvements and changes for custom tags:

- Very minor breaking changes:
  - The (undocumented) onBeforeBind event has been removed
  - Signature change for tag.cvtArgs(): does not accept a converter
    parameter

- 'lateRender' is now available as a tag option (overridden by inline
  lateRender=false)

- 'trigger' is now available as a tag option (overridden by inline
 trigger=...)

- 'linkedElement' and 'linkedCtxParam' can now be set in init()

- If a tag has no args, and argDefault is not set to false, then the
  tagCtx.args[] will be [#data] (where #data is the current data
  context). Note that the render() method will receive the current data
  as parameter. (See https://www.jsviews.com/#tagsapi@argdefault)

Unit tests:

- Several additional unit tests

Documentation:

- JsViews custom tag controls topic has been augmented. (More content to
  be added in next updates) See: http://www.jsviews.com/#jsvtagcontrols
BorisMoore added a commit that referenced this issue Nov 29, 2017
Minor bug fixes:

- Tags and converters with 'depends' as a function: the function now
  receives the tag as 'this' pointer and the contextual data object as
  parameter

- Fix for syntax error bug for debugMode(true) with {{else}} blocks
  https://stackoverflow.com/questions/47065521/migrating-jsrender-to-jsviews-else-issue
  #395

- Fix for bug in advanced nested $.render() call scenarios (when
  useViews advanced setting is false):
  BorisMoore/jsrender#333

- linkedCtxParam bugs:
  - If linkedCtxParam="foo", and onUpdate is not false, two-way binding
    on ~foo continues to work correctly after an update
  - If linkedCtxParam="foo", 2 way binding now works correctly
    for properties of ~foo (~foo.bar...)

- Fix for validation bug for 'preventInvalidData'. Now uses
  onBeforeUpdateValue rather than onBeforeChange

Feature improvements and changes for custom tags:

- Very minor breaking changes:
  - The (undocumented) onBeforeBind event has been removed
  - Signature change for tag.cvtArgs(): does not accept a converter
    parameter

- 'lateRender' is now available as a tag option (overridden by inline
  lateRender=false)

- 'trigger' is now available as a tag option (overridden by inline
 trigger=...)

- 'linkedElement' and 'linkedCtxParam' can now be set in init()

- Calling tag.updateValue() now updates both external bindings and internal
  content dependencies (which it updates by calling tag.setValue()...)

- If a tag has no args, and argDefault is not set to false, then the
  tagCtx.args[] will be [#data] (where #data is the current data
   context). Note that the render() method will receive the current data
   as parameter. (See https://www.jsviews.com/#tagsapi@argdefault)

Unit tests:

- Several additional unit tests

Documentation:

- JsViews custom tag controls topic has been augmented. (More content to
  be added in next updates) See: http://www.jsviews.com/#jsvtagcontrols
@BorisMoore
Copy link
Owner

This has been fixed in release v0.9.90.

pull bot pushed a commit to KiarashS/jsrender that referenced this issue Apr 2, 2020
Sync with changes in v0.9.90 for JsViews

Minor bug fixes, including:

- Fix for syntax error bug for debugMode(true) with {{else}} blocks
  BorisMoore/jsviews#395

- Fix for bug in advanced nested $.render() call scenarios (when
  useViews advanced setting is false):
  BorisMoore#333

Minor change for custom tags:

- If a tag has no args, and argDefault is not set to false, then the
  tagCtx.args[] will be [#data] (where #data is the current data
  context). Note that the render() method will receive the current data
  as parameter. (See https://www.jsviews.com/#tagsapi@argdefault)

Unit tests:

- Some additional unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants