Emmet in JS files

The latest post on this is > 4 years old and (that mentions something about using "Harmony") I believe Intellij has has incorporated emmet expansion capabilities natively with jsx, html, and css files since?

I'm pretty sure I've done this before, but I can't find any settings specific to enabling emmet in js files. How would I do this?

12 comments

Emmet in JSX is supported. Please make sure that Enable JSX Emmet is ticked in Settings | Editor | Emmet | JSX

0

Thanks, but that's not my question. I'm using .js files to write my jsx code and would like to use emmet notation from .js files.

0

and what's a problem? JSX emmet works in .js files - you just need to make sure that javascript language version is set to React JSX to get JSX syntax accepted

0

Oh... I bet that may be it. Sorry about that. My setup here at work works fine. I bet I haven't properly defined my javascript compatibility properly on my home system. I'll try it later today. Thanks!

1

I've enabled this in the settings, however it only works on html section but not the <script> section of html file. Is it possible to enable it on the whole html page? Because often time we construct html fragment in Javascript code.

0

What does your <script> section look like? Please attach screenshots

0

screenshot for the html section, it worked correctly.

 

Screenshot for the script section, Emmets doesn't work.

 

0

HTML is not auto-injected in template string, so you can't expect HTML Emmet to work there. You need to inject HTML in your template to make this work, like

// language=HTML
const m = ``
0

Thanks. This works for that template string.

It doesn't show preview though. Also need the inject for reach template string. Is there a way to inject once and works for the whole file?

0

>It doesn't show preview though

Works for me:

what IDE version do you use?

 

>Is there a way to inject once and works for the whole file?

 

No, it can't be set on file level

0

I'm using IntellijJ IDEA Ultimate 2018.2

0

That's the issue - Emmet preview in injections only works since 2018.3 (https://youtrack.jetbrains.com/issue/WEB-29360)

1

Please sign in to leave a comment.