angular / angular/angular-cli

Add support for "<%_", "_%>" and "-%>" delimiters in templating in @angular-devkit/core

Offen
#23,169 2 Kommentare 5 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: @angular-devkit/core feature feature: in backlog
Vorherrschende Sprache
TypeScript
Sterne
27k
Forks
11.8k
Ø Merge
14 Std. 23 Min.
Gemergte PRs (30 T.)
162

Beschreibung

# 🚀 Feature request

### Command (mark with an `x`)

- [x] generate

### Description

The templating for the @angular/devkit library uses EJS, sort of but doesn't support whitespace slurping the way that the documentation of EJS has declared it. Having this would enable schematic templates to be much more flexible with their whitespace and therefor easier to read while still creating nicely formatted files.

### Describe the solution you'd like

The three delimiters: `"<%_"`, `"_%>"` and `"-%>"` should just be added and work the same way that they do in EJS.

I already have an idea of the code that I'd like to add, and a pull request almost ready. It's very simple and only affects one file.

### Examples

Within [@schematics/angular](https://npmjs.com/package/@schematics/angular) this would allow an example like the following
```
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
<%_ if (routing) { %>
import { AppRoutingModule } from './app-routing.module';
<%_ } -%>
import { AppComponent } from './app.component';

@NgModule({
declarations: [
AppComponent
],
imports: [
<%_ if (routing) { -%>
AppRoutingModule,
<%_ } -%>
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
```

Which would generate with the correct whitespace.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Das Issue identifiziert die Templating-Implementierung von @angular-devkit/core, nennt aber weder eine Datei noch einen Test. Beginne damit, diese Implementierung zu finden, und vergleiche die Behandlung ihrer Delimiter mit EJS; fertig ist es, wenn die Whitespace-verschluckenden Delimiter <%, _%> und -%> für das gezeigte schematische Template funktionieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
tooling
Issue-Typ
Feature
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
28/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.