BorisMoore / jsrender

A lightweight, powerful and highly extensible templating engine. In the browser or on Node.js, with or without jQuery.

Home Page:http://www.jsviews.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

0.9.91 throws syntax error which did not get thrown in 0.9.90

richardgarnier opened this issue · comments

We are using jsrender as a dependency in our project, and the code stopped working recently.
When using the latest version (0.9.91), the following error happens (node v6.12.3, on Windows 10 and Fedora 30).

C:\...\node_modules\jsrender\jsrender-node.js:1722
        throw new $sub.Err(message);

There is a stack that follows, that come from the line:

var jsRender = require('jsrender');

Downgrading to 0.9.90 solves the issue

Can you give both the full stack - (or show a screen shot that has the call stack displayed) and the actual error message that is thrown throw new $sub.Err(message);. All you are saying above is that an error is thrown after you call require('jsrender'). Thanks.

Did you call npm install to install the version v0.9.91?

Yes jsrender was installed through npm install.

The actual message does actually only contains the stack:

[2018-09-25 13:23:07.497] [INFO] generate-input-sanitize - Sanitize functions for client.Command generated at C:\...\sanitize\clientCommand.autogen.js
[2018-09-25 13:23:07.526] [INFO] generate-input-sanitize - Sanitize functions for debug.Command generated at C:\...\sanitize\debugCommand.autogen.js

C:\...\node_modules\jsrender\jsrender-node.js:1722
        throw new $sub.Err(message);
        ^
Error
    at C:\...\node_modules\jsrender\jsrender-node.js:223:27
    at Object.<anonymous> (C:\...\node_modules\jsrender\jsrender-node.js:2753:2)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\...\tools\protobuf\generate_jsdoc.js:9:16)

I tried to reproduce with a simple new project, but the error does not pop up for some reason...

Strange - it should be possible for you to see the actual message string. Can you try to debug where the exception is actually getting thrown, and with what error message - or create some kind of simple repro that I can run...?

Ok, I did not notice that the actual error message was not logged.
I got the following error:

jsrender got error Syntax error
{{else}} block has {{/fi}} without {{fi}}, in template:
{{for fields}}
    {{if notImplemented}}
        // a
    {{else}}
        {{if obsolete}}
            // b
        {{else}}
            {{if field.is_array}}
                {{if optional}}
                    // c
                {{else}}
                    // d
                {{/fi}}
            {{else}}
                {{if optional}}
                    // e
                {{else}}
                    // f
                {{/fi}}
            {{/fi}}
        {{/fi}}
    {{/fi}}
{{/for}}

The template looks correct to me, but I'm not too confident here.

All your closing tags for {{if}} have been written {{/fi}}. It should be {{/if}}, of course, to match the opening tag.

For example:

{{if optional}}
    // c
{{else}}
    // d
{{/if}}

Surprising that you did not get the same syntax error with v0.9.90

I thought I read somewhere that either {{/fi}} or {{/if}} could be used but that may be a misrecollection.

v0.9.90, actually works fine with the fi, and would apparently actually accept anything as closing tag.

Thanks for your time.
I'll close it now, feel free to reopen in case its needed.

Ah yes, I remember I found a bug in v0.9.90 which would have prevented the syntax error from being thrown in some cases, and which I fixed in v0.9.91. That would be why you weren't previously getting the error...