HTML in JS Templates
HTML in JS Templates is a Visual Studio Code extension that provides syntax highlighting for HTML inside JavaScript template literals (backticks ` ).
🛠️ Features
- HTML Syntax Highlighting:
- Enables syntax highlighting for HTML code within JavaScript template literals.
const htmlTemplate = `
<div>
<h1>Hello, World!</h1>
<p>This is highlighted HTML!</p>
</div>
`;
- Preserves JavaScript Highlighting:
- JavaScript expressions inside template literals remain correctly highlighted.
const message = `Result: ${1 + 2}`;
🛠️ Installation
- Open Extensions (
Ctrl+Shift+X ) in Visual Studio Code.
- Search for "HTML in JS Template".
- Click Install.
- Enjoy correct syntax highlighting for HTML inside your JavaScript files!
Alternatively, install it via the command line:
code --install-extension html-in-js-template
💨 Usage
The extension activates automatically when working with JavaScript files (.js ) or TypeScript files (.ts ), and when template literals (` ) are detected.
Example:
const template = `
<div>
<h1>Title</h1>
<p>HTML content is correctly highlighted!</p>
</div>
`;
console.log(`Value: ${42}`);
| |