You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce support for a mappings YAML file to inject key-value pairs
into templates, enhancing the flexibility of generated files. Update
documentation to reflect this new feature and provide usage examples.
Copy file name to clipboardExpand all lines: README.es.md
+53Lines changed: 53 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -377,6 +377,59 @@ files:
377
377
- Si un pre-hook falla, la generación se detiene.
378
378
- Si no se definen hooks, no ocurre nada extra.
379
379
380
+
## 🗺️ Soporte de Mappings
381
+
382
+
Puedes proporcionar un archivo YAML de mappings para inyectar mapas clave-valor en tus plantillas. Esto es útil para referenciar valores específicos de entorno, IDs o cualquier otro mapeo que quieras usar en tus archivos generados.
383
+
384
+
### Ejemplo de archivo de mappings
385
+
386
+
```yaml
387
+
mappings:
388
+
teams:
389
+
devops: devops-team
390
+
aws_account_ids:
391
+
myenv-non-prod: 123456789
392
+
myenv-prod: 987654321
393
+
```
394
+
395
+
### Uso en plantillas
396
+
397
+
Puedes referenciar valores del mapping en tus plantillas usando la variable `mappings`:
398
+
399
+
```jinja
400
+
{{@ mappings.aws_account_ids['myenv-prod'] @}}
401
+
```
402
+
403
+
Esto se renderizará como:
404
+
405
+
```
406
+
987654321
407
+
```
408
+
409
+
### Usar mappings en la cláusula `with`
410
+
411
+
También puedes asignar un valor desde un mapping directamente en la cláusula `with` para llamadas a struct de carpetas. Por ejemplo:
Copy file name to clipboardExpand all lines: README.md
+53Lines changed: 53 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -446,6 +446,59 @@ files:
446
446
- If a pre-hook fails, generation is halted.
447
447
- If no hooks are defined, nothing extra happens.
448
448
449
+
## 🗺️ Mappings Support
450
+
451
+
You can provide a mappings YAML file to inject key-value maps into your templates. This is useful for referencing environment-specific values, IDs, or any other mapping you want to use in your generated files.
452
+
453
+
### Example mappings file
454
+
455
+
```yaml
456
+
mappings:
457
+
teams:
458
+
devops: devops-team
459
+
aws_account_ids:
460
+
myenv-non-prod: 123456789
461
+
myenv-prod: 987654321
462
+
```
463
+
464
+
### Usage in templates
465
+
466
+
You can reference mapping values in your templates using the `mappings` variable:
467
+
468
+
```jinja
469
+
{{@ mappings.aws_account_ids['myenv-prod'] @}}
470
+
```
471
+
472
+
This will render as:
473
+
474
+
```
475
+
987654321
476
+
```
477
+
478
+
### Using mappings in the `with` clause
479
+
480
+
You can also assign a value from a mapping directly in the `with` clause for folder struct calls. For example:
This will assign the value `devops-team` to the variable `team` and `987654321` to `account_id` in the struct, using the values from your mappings file.
493
+
494
+
### Passing the mappings file
495
+
496
+
Use the `--mappings-file` argument with the `generate` command:
0 commit comments