angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

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

Open vector67 opened this issue 3 years ago • 2 comments

🚀 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 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.

vector67 avatar May 18 '22 14:05 vector67

Looking forward to this feature 🙏🙏

andresjosehr avatar Feb 03 '23 04:02 andresjosehr

This feature would be great 👍

field123 avatar Sep 23 '23 19:09 field123