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

ejs throws error <%= ":" _ %> for a space between _ and %> - SyntaxError: missing ) after argument list #334

Closed
moorthi07 opened this issue Jan 8, 2018 · 6 comments

Comments

@moorthi07
Copy link

I had this error thrown by ejs which ejs-lint couldn't detect.


err SyntaxError: missing ) after argument list in C:\model.ts while compiling ejs

If the above error is not helpful, you may want to try EJS-Lint:
https://github.com/RyanZim/EJS-Lint

for a code like,

<%= ":" _ %>

First of all it should not throw an error as this code has both <% and %>. But this ejs detects this space (' ') between _ %> and throws an error.

It could be a meaning full error , may be like , its missing a closing '%>' - would be more appropriate.

But it was very hard for me to locate this little space in the large file!

@mde
Copy link
Owner

mde commented Jan 8, 2018

In this case, the error is not coming from the EJS tag-matching code. It an ordinary JavaScript SyntaxError being thrown trying to parse ":" _, which is not valid JavaScript. This is not something ejs-lint can lint for -- it's actually valid EJS tags, just invalid JavaScript inside them. I agree it's not a super-helpful error message, and sounds like it was difficult to find. I understand how frustrating that is. Since this isn't an error specific to EJS, I'm going to go ahead and close this issue.

@mde mde closed this as completed Jan 8, 2018
@moorthi07
Copy link
Author

That's beautiful catch. Thanks.
Problem is we cannot lint code for any language until the output rendered by ejs, right? How would you go about linting before hand (apart from being careful with syntax) or a way to get the 'ejs continue render and we run another lint on the output'!

@suab321321
Copy link

Just for extra information if someone is using a condition in ejs
<%= typeof err !='undefined'?err:'Successful'%> the issue may also arise if you use this : before this?

@milleymilli
Copy link

milleymilli commented Nov 6, 2019

this is how it looks like my index.ejs,,,

`` and this is my app.js,,,,,, app.get('/', (req, res) => { res.render('index', { nav: [{ link: '/books', title: 'Books' }, { link: '/authors', title: 'Author' }], title: 'My App' }); });

but when i inspect my web page am getting my anchor values a[ object object ],,,,,,any suggestion @mde ``

@suab321321
Copy link

@milleymilli your each element of the array is of json type {link:'',title:''},html cannot render this json object..it needs a particular value like integer,string,etc..
Example:
<%=nav[index].link%>
this will be rendered because it is actually giving html a value and not a json object.

@HASSANALI2022
Copy link

<% if(kindOfDay === "Saturday" || kindOfDay === "Sunday"){ %>

<%= kindOfDay%> ToDo List


<% } else %>
{

<%= kindOfDay%> ToDO List


<% } %>
SyntaxError: Missing catch or finally after try in C:\Users\Admin\desktop\to-do-list\views\List.ejs while compiling ejs

If the above error is not helpful, you may want to try EJS-Lint:

Repository owner locked as resolved and limited conversation to collaborators Dec 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants