-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add string matching helper functions to Go templates #6370
Comments
@iilyak Thanks for writing in. Is the extension that you are working on written in bash? This repo is for the |
The cli/cli calls out into go-gh to handle template rendering here (template module is imported here). For the context I am trying to do something similar to https://github.com/samcoe/gh-triage/blob/main/gh-triage
However in my case all labels in the condition would be prefixed with
|
@iilyak Thank you for the feature request! Agreed that adding some string helpers would be really helpful. Related: #5976 (reply in thread) |
hello, # posted by iilyak
{{- if hasPrefix $label.name "project:" -}}
# printf
{{- if eq (printf "%.8s" $label.name) "project:" -}} 💁 |
@iamazeem Thanks for opening a PR for this and being patient while we review and discuss! ❤ I've discussed this with @jtmcg and we want to change the expected output for this. We believe this would be better implemented in We think this might go here: https://github.com/cli/go-gh/blob/13104ed7b2db4b8c1a83de4248ddfaaab7682916/pkg/template/template.go#L36 |
@iamazeem & anyone else reading: The team has been continuing to discuss this, and we also want this work to limit the functions we import from
We think that importing all the functions is a bit more "unknown" surface area than what we are comfortable with. This filtering would likely be done by calling |
@BagToad: Sounds good to me. 👍
Not all of these |
@BagToad: PR cli/go-gh#184 created. Please review. Thanks! |
In a
gh
extension (written in bash) I needed to implement a fuzzy matching on the content of a label. Specifically I needed to exclude issues which has a label withproject:
prefix. However, I couldn't find any functions in https://github.com/cli/go-gh/blob/trunk/pkg/template/template.go or standard go templates to supportstartsWith
.There are quite a few string related function in https://github.com/Masterminds/sprig including the function which would help in my case:
If inclusion of sprig into go-gh is not an option, would it be possible to implement at least
contains
in thepkg/template/template.go
?The text was updated successfully, but these errors were encountered: