Add templating feature for "from" file/template #2312
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
I wanted to have an easy way to select different kind of license for my projects based on defined template. Unfortunately, rebar3 supports variable templating only on the target files and templates' names. I added the support of templating in the
From
part of the execution. That means it is now possible to add a variable in the source and not only the destination. Here an exemple:By default, the
license
variable is set toapache-2.0
but we can select any other variables. If the file_app/LICENSE-{{license}}
exists, the file will be copied in{{name}}/LICENSE
. A whole working example exist in my rebar3_templates own's repository. By adding the template_app
in${HOME}/.config/rebar3
, I can know use different available license:I did not add a check if the file exist or not. If the license does not exist, rebar3 will crash.
EDIT: tested on OpenBSD-current.