A powerful VS Code extension that streamlines Angular component development by providing seamless functionality to move templates and styles between inline and external files. Whether you're refactoring existing components or organizing your codebase, Angular Template Mover makes it effortless to switch between different template and style patterns.
Angular Template Mover provides six comprehensive commands for Angular component management, all conveniently grouped under the "Angular Template Mover" submenu:
Command | Description | Input | Output |
---|---|---|---|
Extract Template to File | Extracts inline templates to separate HTML files | template: '...' |
templateUrl: './component.html' |
Extract Styles to File | Extracts inline styles to separate style files | styles: ['...'] |
styleUrls: ['./component.css'] |
Inline Template from File | Moves external templates back to inline | templateUrl: './component.html' |
template: '...' |
Inline Styles from File | Moves external styles back to inline | styleUrls: ['./component.css'] |
styles: ['...'] |
Command | Description | Action |
---|---|---|
Move to Inline Template | Converts external HTML template to inline | Automatically finds the corresponding component and inlines the template |
Command | Description | Action |
---|---|---|
Move to Inline Styles | Converts external style files to inline | Automatically finds the corresponding component and inlines all referenced styles |
- Install the extension from the VS Code Marketplace
- Open your Angular project in VS Code
- Access the extension using one of three methods:
- Right-click on files in Explorer β "Angular Template Mover"
- Right-click in editor β "Angular Template Mover"
- Command Palette (Ctrl+Shift+P) β Type "Angular Template Mover"
- Choose your desired action from the available commands
- Follow the prompts for file operations and optional deletions
Before:
@Component({
selector: 'app-example',
template: `
<div class="container">
<h1>{{title}}</h1>
<p>Welcome to our application!</p>
</div>
`,
styleUrls: ['./example.component.css']
})
export class ExampleComponent {
title = 'My App';
}
After:
@Component({
selector: 'app-example',
templateUrl: './example.component.html',
styleUrls: ['./example.component.css']
})
export class ExampleComponent {
title = 'My App';
}
Right-click on example.component.html
β Angular Template Mover β Move to Inline Template
Angular Template Mover can be accessed through three different methods for maximum convenience:
- Open your Angular project in VS Code
- Navigate to the Explorer panel (Ctrl+Shift+E)
- Right-click on any supported file:
.ts
files (component files).html/.htm
files (template files).css/.scss/.sass/.less
files (style files)
- Select "Angular Template Mover" from the context menu
- Choose your desired action from the submenu
- Open a supported file in the editor
- Right-click anywhere in the editor content
- Select "Angular Template Mover" from the context menu
- Choose your desired action from the submenu
- Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
- Type "Angular Template Mover" or any of these commands:
Angular Template Mover: Extract Template to File
Angular Template Mover: Extract Styles to File
Angular Template Mover: Inline Template from File
Angular Template Mover: Inline Styles from File
Angular Template Mover: Move to Inline Template
Angular Template Mover: Move to Inline Styles
- Select the command you want to execute
- The extension will operate on the currently active file
The extension intelligently shows relevant commands based on the file type:
File Type | Available Commands |
---|---|
.ts files |
All extraction and inlining commands |
.html/.htm files |
Move to Inline Template |
Style files (.css , .scss , .sass , .less ) |
Move to Inline Styles |
- Explorer context menu: Best for batch operations on multiple files
- Editor context menu: Quick access while editing a specific file
- Command palette: Fastest access via keyboard shortcuts, works with active file
- VS Code: 1.104.0 or higher
- Angular: Any version with TypeScript components
- File Structure: Standard Angular component naming conventions
- β Multiple Style Preprocessors: CSS, SCSS, SASS, LESS
- β Smart File Detection: Automatically finds corresponding component files
- β Safe Operations: Prompts before deleting files
- β Error Handling: Comprehensive error messages and validation
- β Template Preservation: Maintains formatting and structure
- β
Batch Style Processing: Handles multiple style files in
styleUrls
- Requires standard Angular naming conventions (
component-name.component.ts
) - Only supports string templates (backticks, single, and double quotes)
- Template extraction preserves exact formatting but may need manual adjustment
- Component metadata parsing uses
eval()
for complex object structures
- Support for custom naming conventions
- Batch processing for multiple files
- Integration with Angular CLI
- Template and style validation
- Undo/Redo functionality
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Author: Adilson de Almeida Pedro
Website: https://adilson.almeidapedro.com.br
GitHub: @devremoto
Twitter: @devremoto
LinkedIn: Adilson Pedro
This project is licensed under the MIT License - see the LICENSE.txt file for details.
If you encounter any issues or have questions:
- Check the Known Limitations section
- Search existing issues
- Create a new issue with detailed reproduction steps
- Thanks to the Angular team for creating an amazing framework
- Inspired by the need for better developer experience in Angular projects
- Built with love for the Angular community by Adilson de Almeida Pedro
Enjoy coding with Angular Template Mover! π
Created by Adilson de Almeida Pedro - Full Stack Developer