Add support for "<%_", "_%>" and "-%>" delimiters in templating in @angular-devkit/core
- 主要语言
- TypeScript
- 星标
- 27k
- 派生
- 11.8k
- 平均合并
- 14 小时 23 分钟
- 30 天内合并 PR
- 162
描述
# 🚀 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.
贡献指南
调研方向
该 issue 指出了 @angular-devkit/core 的模板实现,但没有指定文件或测试。首先定位该实现,并将其分隔符处理方式与 EJS 进行比较;对于所示的 schematic template,当去除空白的分隔符 <%、_%> 和 -%> 能够正常工作时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- tooling
- Issue 类型
- 功能
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 28/100