Repository navigation
add "replace" from sprig to go template functions #11572
Description
Activity
github-actions commented
on Aug 25, 2025 on Aug 25, 2025 – with GitHub ActionsContributorMore actionsThank you for your issue! We have categorized it as a feature request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.
Unless you see the help wanted
Contributions welcome label, we are not currently looking for external contributions for this feature.If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.
👋 Hey @armindarvish, thank you for writing this up! ✨
Sounds reasonable to me! 👍
Implementation notes:
We intentionally limit our exposure to all the Sprig functions, so adding this one requires adding
replaceto this func map.Note that this code is in
go-gh, so to implement this we need the following, in this order:- A PR opened in
cli/go-ghto introduce that func. - Some testing done by locally building
cli/cliwith thecli/go-ghchanges to demonstrate the new func is included and works as expected.- Go workspaces can be helpful for this 👍
- (maintainers only) A release cut for
cli/go-gh - A PR opened in
cli/clito upgradecli/go-gh. Usually, Dependabot does this for us, but it depends on the version bump.
Intentionally no explicit acceptance criteria - the above should suffice.
- A PR opened in
- addedhelp wantedContributions welcomeContributions welcomeand removedneeds-triageneeds to be reviewedneeds to be reviewed
on Aug 25, 2025 - added a commit that references this issue
on Aug 25, 2025 @BagToad: PR cli/go-gh#196 opened and it's ready for review. Thanks!
cli/go-gh#196 merged.
Reacted by Azeem- added a sub-issue
on Oct 28, 2025 fixed by #12095
Describe the feature or problem you’d like to solve
I am trying to use the "--template" formatting with
gh search issues, and I want to remove newlines from the title of the issues. I tried using{{.title | replace \"\n\" " "}}:I get an error saying:
the function "replace" is not defined
There is a replace function available in the "sprig library", but it appears that this is not available in gh.
Proposed solution
Add the replace function from sprig library for go template formatting.