This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 267488 - Please add syntax highlighting and code completion for HTML inside a string in JS files
Summary: Please add syntax highlighting and code completion for HTML inside a string i...
Status: CLOSED INVALID
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.1
Hardware: PC Other
: P3 normal with 3 votes (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-08 15:20 UTC by Christian Lenz
Modified: 2018-11-09 14:44 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Lenz 2016-08-08 15:20:04 UTC
In the new react implementation in NB 8.2 we have syntax highlighting and code completion for HTML inside JS (JSX support). This is really great. For this you have to right this.

return {
   <div>...
}

works great but if you have this inside a normal js file, independent from a framework:

let test = '<div *ngFor="let item of items"></div>';

or

myElem.innerHTML = '<div>somthing</div>';

there is no syntax highlighting and no code completion for HTML inside strings in js files. Often you have such things like in Angular directives, for the template property or in Angular2 (TypeScript or no, it doesn't matter, would I say) inside a component for the template property.

So what I really would like to see is that we can have full html support with syntax highligting and code completion for HTML AND JS stuff like you can see in my first example. There is HTML and JS mixed in one string.


Regards

Chris
Comment 1 Petr Pisl 2016-08-08 20:10:17 UTC
I remember the discussion whether provide html syntax coloring in strings for other languages. The result was not provide such syntax coloring. The main reason was to recognize the string at first view and to be compatible with java doc, where the html tags are not also colored. 

I'm OK with providing code completion in these situations. But it will not be connected with the jsx support. It will be provided in every string in js file.
Comment 2 Christian Lenz 2016-08-09 06:59:46 UTC
Of course it is not connected or related to the JSX support, I only wanted to say, if it's possible to bring HTML syntax highlighting and code completion support to JS files, which supports React, than it should also be possible to bring the same for strings, because often you have cases where you have languages in strings, in other languages.
Like SQL in Java, SQL in PHP where those should syntax highlighted too and should support code completion too, because this reduces the amount of misstyping smth.

Strings are not really helpful in most of the cases. If we can have HTML syntax highlighting and code completion support in strings, mostly for js, php and don't know for java but I think there exists such cases too this will increase productivity and reduce errors of misstyping.

I know for PHP and for java I have to create separate tickets but these cases are real and exists. For JS it exists for inline HTML in JS files to create elements and assign it to innerHTML for example or for templates in Angular and Angular2.
Comment 3 murtukov 2016-10-06 13:53:09 UTC
I am agree with Chris. The syntax highlighting in strings would be great. In PHPStrom it is already implemented and works great.
Comment 4 Christian Lenz 2016-11-13 14:17:44 UTC
SQL in JS is also needed, because of node, we can have inline SQL inside js files: https://github.com/mysqljs/mysql

I can create a new ticket for this enhancement, if you want.
Comment 5 Christian Lenz 2017-04-07 07:12:02 UTC
Now there is a plugin to bring exactly this behaviour into Visual Studio Code: https://marketplace.visualstudio.com/items?itemName=natewallace.angular2-inline the thing is more and more frameworks can work with inline templates. And JS can handle this from the beginning. So this is really needed and a must have to bring both together.
Comment 6 Christian Lenz 2018-11-09 14:43:26 UTC
I will close it, because it will handled now at the JIRA board: https://issues.apache.org/jira/browse/NETBEANS-1649. Please discuss it there for further information.