bazel-contrib / bazel-contrib/bazel-lib

[FR] regex substitution support in expand_template

Open
#1,192 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
182
Forks
134
Avg merge
1d 46m
Merged PRs (30d)
1

Description

It would be very helpful to be able to match using regex in expand_template:

```
expand_template(
regex_substitutions = {
"^whole_line$": "replace_whole_line"
"capture (\w+) something": "use $1 in a replacement"
"^delete_line$\n": ""
}
)
```

It seems like a fairly straightforward implementation given https://github.com/bazel-contrib/bazel-lib/blob/main/tools/expand_template/main.go already exists; we would always use this engine when regex_substitutions was set.

We could contribute this; would it be welcome?

Thanks!

Contributor guide

Open the contributing guide

Research direction

Start with the expand_template entry point and read tools/expand_template/main.go, which the issue identifies as the existing engine. Define the supported regex_substitutions behavior from the examples, including captures and whole-line deletion, and verify that expand_template uses this engine whenever the option is set.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.