ejs-grammar icon indicating copy to clipboard operation
ejs-grammar copied to clipboard

EJS tags within <script> tags in a .ejs file appear as errors.

Open N00dleMaster opened this issue 3 years ago • 14 comments

Steps to reproduce:

<script>
    const test = <%= thisVariableWasPassedToTheEjsFile %>
</script>

Expected result:

The EJS tags within <script> tags appear with red squiggly lines underneath them. The code still works, so it's not a huge problem, but I do find the lines a tad annoying.

N00dleMaster avatar Apr 06 '21 14:04 N00dleMaster

Confirmed: EJS tags inside Javascript code trigger an JS error ("Expression expected"). This seems to me to be a fundamental bug.

rudosch avatar Apr 09 '21 19:04 rudosch

Hi, I experience it too, any news about this?

stephaned-ev avatar May 13 '21 17:05 stephaned-ev

Im having the same issue also with style tags and in attributes

AurangAsif avatar May 18 '21 23:05 AurangAsif

I Have a Error with this:

In this point nt%>">" with Error "at-rule or selector expectedcss(css-ruleorselectorexpected)" Thanks for you work. so usefull.

emanavas avatar Sep 08 '21 16:09 emanavas

Confirmed. This is driving me bonkers.

Greg-J avatar Sep 16 '21 00:09 Greg-J

Hey all,

This looks like an error with the linter. The syntax highlighter does not throw any errors. The only error you would get from this (and may be the case as well, would the color would not be colored correctly)

I know this doesn't help, but maybe look into the different linters you have installed. One of them is probably throwing the error.

On Wed, Sep 15, 2021, 8:29 PM Greg-J @.***> wrote:

Confirmed. This is driving me bonkers.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Digitalbrainstem/ejs-grammar/issues/78#issuecomment-920483315, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMHQ7AR6JCCWNDMT4CIIZLUCE27VANCNFSM42O4OUZQ .

Betanu701 avatar Sep 16 '21 00:09 Betanu701

I'm having the same issue, and I disabled the only Linter i had installed and the error persisted. const campground = <%-JSON.stringify(campground)%>;

davidbdyer avatar Sep 28 '21 16:09 davidbdyer

The main reason why I'm trying to find a working EJS extension is to be able to both

  • write and work in EJS files without getting linting errors because of EJS tags
  • still get language support for the surrounding languages

Without that, working with EJS in VS Code is a nightmare :(

Hey all, This looks like an error with the linter. The syntax highlighter does not throw any errors. The only error you would get from this (and may be the case as well, would the color would not be colored correctly) I know this doesn't help, but maybe look into the different linters you have installed. One of them is probably throwing the error. On Wed, Sep 15, 2021, 8:29 PM Greg-J @.***> wrote: Confirmed. This is driving me bonkers. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#78 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMHQ7AR6JCCWNDMT4CIIZLUCE27VANCNFSM42O4OUZQ .

Are you saying you've got a working set-up? Which linters do you use? And how do I disable which ever internal linter is throwing these errors?

Black-Platypus avatar Dec 23 '21 14:12 Black-Platypus

Has there been any update on this issue?

yorkeJohn avatar Apr 05 '23 00:04 yorkeJohn

Nothin'.

N00dleMaster avatar Apr 05 '23 02:04 N00dleMaster

The only solution seems to be to disable validation of JS within script tags: "html.validate.scripts": false

However, this is not ideal, because actual errors are no longer detected within script tags.

yorkeJohn avatar Apr 05 '23 16:04 yorkeJohn

has anyone found a good solution to this yet?

Menacer20 avatar Dec 06 '23 12:12 Menacer20

fyi, incase it helps anyone, my current approach to prevent the issue is <%- "<script> const existingData = "+JSON.stringify(existingData)+"; </script>"; %> it wont be a solution for every situation, and its less than ideal. but better then the false flag error highlighting

Menacer20 avatar Dec 06 '23 12:12 Menacer20

I found another way to do it (thank you chatGPT). in the ejs file i enter this:

and later on to use it:

I do not have any error flags now :). Worked for me, and maybe will help someone.

werneroi avatar Jan 15 '24 12:01 werneroi