Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Angular schematics generates blank lines through template

Đang mở
#27,896 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
angular, typescript
Lĩnh vực
cli, tooling

Hướng nghiên cứu

Tái hiện các dòng trống từ schematic template inline <% ... %> bằng npm run build và schematics .:ui-generator --name=hello. Bắt đầu bằng cách truy vết cách Angular CLI schematics render các lệnh template, sau đó xác minh rằng đầu ra được tạo bỏ qua khoảng trắng chỉ thuộc về lệnh trong khi vẫn giữ nguyên nội dung xung quanh.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area: @angular-devkit/schematics freq1: low severity2: inconvenient type: bug/fix workaround2: non-obvious
Command

generate

Is this a regression?
  • Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was

No response

Description

I have ng schematics template __name@dasherize__.component.html with content :

<% for (let row of getComponents().rows) { %>
<div class="row">
  <% for (let field of row.fields) { %>
  <% if (field.type === 'InputStrxing') { %>
  <field labelCode="code" class="col-sm-6 col-md-3">
    <input name="code" ngModel [readonly]="readOnly">
  </field>
  <% } %>
  <% } %>
</div>
<% } %>

I build it with :

npm run build 
schematics .:ui-generator --name=hello

Generated code creates empty lines on place where is put command "<%" in template, see:

<div class="row">
  
  
  <field labelCode="code" class="col-sm-6 col-md-3">
    <input name="code" ngModel [readonly]="readOnly">
  </field>
  
  
  
  <field labelCode="code" class="col-sm-6 col-md-3">
    <input name="code" ngModel [readonly]="readOnly">
  </field>
  
  
  
  <field labelCode="code" class="col-sm-6 col-md-3">
    <input name="code" ngModel [readonly]="readOnly">
  </field>
  
  
  
  
</div>

Is there anyway these white spaces can be avoided. If we have to do it manually, it might kill the purpose of this code generator tool

Minimal Reproduction

Write a schematic template code with inline code <% inline code %>. Then build and generate code using commands

npm run build 
schematics .:ui-generator --name=hello

We can see generated code is having while spaces wherever inline code is present.

Exception or Error

No response

Your Environment
ng analytics disable --global

Global setting: enabled
Local setting: No local workspace configuration file.
Effective status: enabled

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 16.2.14
Node: 18.19.1
Package Manager: npm 10.2.4
OS: darwin arm64

Angular: undefined
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1602.14
@angular-devkit/core         16.2.14
@angular-devkit/schematics   16.2.14
@schematics/angular          16.2.14
typescript                   5.1.6
Anything else relevant?

No response

Ngôn ngữ chính
TypeScript
Star
27k
Fork
11.8k
Merge trung bình
17 giờ 25 phút
Pull request đã merge (30 ngày)
183

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của angular/angular-cli

Tất cả issue của angular/angular-cli

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.