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

Error when use some javascript expression #6

Closed
dhanyg opened this issue Jul 19, 2021 · 2 comments
Closed

Error when use some javascript expression #6

dhanyg opened this issue Jul 19, 2021 · 2 comments

Comments

@dhanyg
Copy link

dhanyg commented Jul 19, 2021

Hello, i'm trying using edge with express. However i got error when try using javascript typeof and optional chaining inside .edge file.
The code:

@if(typeof errors != 'undefined')
    <div class="alert alert-danger" role="alert">
        {{errors.testFile?.msg}}
    </div>
@endif

The errors:

undefined:20
  if (typeofthis.context.resolve('errors') !== 'undefined') {
  ^

ReferenceError: typeofthis is not defined
    at Template.templateFn (eval at run (D:\Dev\node\belajar-fileupload\node_modules\edge.js\src\Template\Runner.js:51:20), <anonymous>:20:3)
    at Template.eval (eval at run (D:\Dev\node\belajar-fileupload\node_modules\edge.js\src\Template\Runner.js:51:20), <anonymous>:41:14)  
    at TemplateRunner.run (D:\Dev\node\belajar-fileupload\node_modules\edge.js\src\Template\Runner.js:54:39)
    at Template.renderString (D:\Dev\node\belajar-fileupload\node_modules\edge.js\src\Template\index.js:338:55)
    at Edge.renderString (D:\Dev\node\belajar-fileupload\node_modules\edge.js\src\Edge\index.js:178:23)
    at D:\Dev\node\belajar-fileupload\node_modules\express-edge\dist\index.js:44:34
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)
[nodemon] app crashed - waiting for file changes before starting...
D:\Dev\node\belajar-fileupload\node_modules\edge.js\src\Template\index.js:305
      throw (this._prepareStack('raw string', error))
      ^

InvalidExpressionException: lineno:19 charno:22 E_INVALID_EXPRESSION: Invalid expression <errors.testFile?.msg>
    at Function.invalidLineExpression (D:\Dev\node\belajar-fileupload\node_modules\edge.js\src\Exceptions\index.js:105:19)
    at D:\Dev\node\belajar-fileupload\node_modules\edge.js\src\Template\Compiler.js:68:45
    at String.replace (<anonymous>)
    at TemplateCompiler._interpolateMustache (D:\Dev\node\belajar-fileupload\node_modules\edge.js\src\Template\Compiler.js:55:17)
    at TemplateCompiler.parsePlainLine (D:\Dev\node\belajar-fileupload\node_modules\edge.js\src\Template\Compiler.js:170:36)
    at TemplateCompiler.parseLine (D:\Dev\node\belajar-fileupload\node_modules\edge.js\src\Template\Compiler.js:189:10)
    at D:\Dev\node\belajar-fileupload\node_modules\edge.js\src\Tags\IfTag.js:93:40
    at Array.forEach (<anonymous>)
    at IfTag.compile (D:\Dev\node\belajar-fileupload\node_modules\edge.js\src\Tags\IfTag.js:93:12)
    at TemplateCompiler.parseTag (D:\Dev\node\belajar-fileupload\node_modules\edge.js\src\Template\Compiler.js:152:21) {
  lineno: 19,
  charno: 22
}

Previously i used that expression in ejs template and it works.
Any suggestion? Thanks before..

@ecrmnn
Copy link
Owner

ecrmnn commented Jul 22, 2021

Hi
I've made this adapter to use Edge with Express, but unfortunately I can't help you with Edge issues.
Maybe you can find help here, https://github.com/edge-js/edge

@ecrmnn ecrmnn closed this as completed Jul 22, 2021
@dhanyg
Copy link
Author

dhanyg commented Jul 23, 2021

Thanks for the reply, and many thanks for your effort. I really like this template engine. Btw for my issues, I have found alternative solution..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants