Skip to content

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

Description

@vector67

🚀 Feature request

Command (mark with an 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.

Activity

  1. added
    needs: discussion
    on May 19, 2022
  2. added this to the needsTriage milestone on May 19, 2022
  3. removed
    needs: discussion
    on Jun 16, 2022
  4. added
    feature: in backlog
    feature
    on Nov 30, 2022
  5. andresjosehr commented on Feb 3, 2023

    @andresjosehr

    Looking forward to this feature 🙏🙏

  6. field123 commented on Sep 23, 2023

    @field123

    This feature would be great 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: @angular-devkit/corefeaturefeature: in backlog

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions