Angular schematics generates blank lines through template
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- angular, typescript
Research direction
Reproduce the blank lines from the inline <% ... %> schematic template using npm run build and schematics .:ui-generator --name=hello. Start by tracing how Angular CLI schematics render template commands, then verify that generated output omits command-only whitespace while preserving the surrounding content.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- TypeScript
- Stars
- 27k
- Forks
- 11.8k
- Avg merge
- 16h 35m
- Merged PRs (30d)
- 176
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from angular/angular-cli
-
area: @angular/build gemini-triaged
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
angular/angular-cli#33955 ·
-
area: @angular/cli gemini-triaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
angular/angular-cli#33055 · 1 comment · 3 reactions ·
-
area: @angular/build gemini-triaged
Difficulty 4/5 3-5 days Newbie friendliness 72/100
angular/angular-cli#34137 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 1 assignee ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34130 · 1 assignee ·
All issues in angular/angular-cli
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
ontola/atomic-server#1625 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
melgarafael/DeskcommCRM#1451 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
-
bug via-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bot:ai-assisted component:compact-js status:untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
midnightntwrk/midnight-sdk#403 ·