angular / angular/angular-cli

Angular schematics generates blank lines through template

Abierto
#27,896 1 comentario 0 reacciones 0 asignados Ver en GitHub
area: @angular-devkit/schematics freq1: low severity2: inconvenient type: bug/fix workaround2: non-obvious
Lenguaje dominante
TypeScript
Estrellas
27k
Forks
11.8k
Merge medio
14 h 23 min
PR fusionados (30 d)
162

Descripción

### 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) { %>
>


> <% for (let field of row.fields) { %>
> <% if (field.type === 'InputStrxing') { %>
>
>
>
> <% } %>
> <% } %>
>

> <% } %>

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:

>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

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

```text
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_

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Reproduce las líneas en blanco de la plantilla schematic inline <% ... %> usando npm run build y schematics .:ui-generator --name=hello. Empiece siguiendo cómo Angular CLI schematics renderiza los comandos de plantilla y, después, verifique que la salida generada omite los espacios en blanco exclusivos de los comandos mientras conserva el contenido circundante.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
cli, tooling
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.