Is there a way (plugin, option, or tip and trick) to highlight HTML syntax in a JS string?
My document is a .js
file, in which I use strings containing HTML code. Is it possible to highlight HTML syntaxe inside these strings?
Is there a way (plugin, option, or tip and trick) to highlight HTML syntax in a JS string?
My document is a .js
file, in which I use strings containing HTML code. Is it possible to highlight HTML syntaxe inside these strings?
You can use the extension es6-string-html
Note: You need to add a comment with the language in front of the multiline string
The extension that you suggested requires that you prefix your strings with a comment like /*html*/
or html
. I'm working with Angular, and I didn't want to go through all my templates to prefix them, so I found this extension that does it automatically without prefixes:
https://marketplace.visualstudio.com/items?itemName=natewallace.angular2-inline
It is included in the Angular Essentials package by John Papa:
https://marketplace.visualstudio.com/items?itemName=johnpapa.angular-essentials
You can try the extension leet-html. It works fine, without any prefix or comment to add, and not related to any framework.
For Vue try Vue Inline Template:
https://marketplace.visualstudio.com/items?itemName=faisalhakim47.vue-inline-template
© 2022 - 2025 — McMap. All rights reserved.