Component Template Formatting & Auto Complete

Open
#484 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
angular, typescript
Domain
tooling

Research direction

No files, tests, or entry points are named in the issue. Start by locating the Sublime plugin's handling for Angular component templates, formatting, and autocomplete; done means preserving template formatting and providing useful element completion inside the template.

Written by the indexing model from the issue text.

Description

Enhancement

I don't think these are bugs, just a features that are missing/needed/would be super nice to have.

Component Template Formatting
When inside of a @Component using `` it does not respect the formatting and always removes it when formatting your code. In VisualStudio Code it doesn't format the code automatically, but it does respect the formatting you give it. In Sublime it just aligns everything on one level for almost everything. Some things like [ngClass] it does indent, but most other things do not. This formatting does seem to work for "Styles", but not "template".

Ex.

import {Component, Input} from 'angular2/core';

@Component({
    selector: 'zippy',
    styles: [`
    .zippy {
        border: 1px solid #ccc;
        border-radius: 2px;
    }

    .zippy .zippy-title {
        padding: 20px;
        font-weight: bold;
    }

    .zippy .zippy-title:hover{
        background: #f0f0f0;
        cursor: pointer;
    }

    .zippy .zippy-content {
        padding: 20px;
    }
    `],
    template: `
    <div class="zippy">
    <div
    class="zippy-title"
    (click)="toggle()">
    {{ title }}
    <i
    class="pull-right glyphicon"
    [ngClass]="
    {
        'glyphicon-chevron-down': !isExpanded,
        'glyphicon-chevron-up': isExpanded
    }">
    </i>
    </div>
    <div *ngIf="isExpanded" class="zippy-content">
    <ng-content></ng-content>
    </div>
    </div>
    `
})
export class ZippyComponent {
    isExpanded = false;
    @Input() title: string;

    toggle() {
        this.isExpanded = !this.isExpanded;
    }
}

Auto Complete
Again when inside of @Component "template" auto-complete does not exist, which gets very cumbersome very fast. It would be nice if there was a way to have elements auto complete here.

Dominant language
JavaScript
Stars
1.7k
Forks
236
Avg merge
21d 13h
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/TypeScript-Sublime-Plugin

All issues in microsoft/TypeScript-Sublime-Plugin

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.