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
Copy file name to clipboardExpand all lines: README.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -162,6 +162,7 @@ Learn more about boilerplate in the following sections:
162
162
1.[Template helpers](#template-helpers)
163
163
1.[Deprecated helpers](#deprecated-helpers)
164
164
1.[Partials](#partials)
165
+
1.[Advanced use cases](#advanced-use-cases)
165
166
166
167
#### Boilerplate command line options
167
168
@@ -1120,6 +1121,33 @@ partials:
1120
1121
- "{{ .TemplatesRoot }}/css/*.css"
1121
1122
```
1122
1123
1124
+
## Advanced use cases
1125
+
1126
+
### Dynamic file naming
1127
+
1128
+
Boilerplate supports using variables and template helpers directly in filenames. This allows you to dynamically generate file names based on the variables you define in your `boilerplate.yml` file.
1129
+
1130
+
For example, with the following variable definition:
1131
+
1132
+
```yaml
1133
+
variables:
1134
+
- name: Singular
1135
+
description: The singular form the noun, e.g. BigWidget
1136
+
```
1137
+
1138
+
You can create a template file named `{{ .Singular | snakeCase }}_entity.go` which will generate a file like `big_widget_entity.go` when the Singular variable is set to "BigWidget".
1139
+
1140
+
Another example:
1141
+
1142
+
```yaml
1143
+
variables:
1144
+
- name: RootTerragruntFileName
1145
+
type: string
1146
+
default: "root.hcl"
1147
+
```
1148
+
1149
+
With this variable, you can have a template file named `{{ .RootTerragruntFileName }}` which will generate a file named according to the value of RootTerragruntFileName.
1150
+
1123
1151
## Alternative project generators
1124
1152
1125
1153
Before creating Boilerplate, we tried a number of other project generators, but none of them met all of our
0 commit comments