Skip to content

Add sprig library for template functions. #2741

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

Merged
merged 1 commit into from
Mar 22, 2022

Conversation

kevinbarbour
Copy link
Contributor

Add sprig library for template functions.

Fixes #2737
Alternative to #2738

Removes duplicates from the funcMap that exist already in sprig.
Note that this does leave the hasPrefix function overriding the one in
sprig. This is because the sprig function expects arguments of the form
(prefix, string) and the existing go-swagger function expects
(string, prefix).

As to not cause a breaking change to the existing templating this was
left as-is.

Signed-off-by: Kevin Barbour kevinbarbourd@gmail.com

Fixes go-swagger#2737
Alternative to go-swagger#2738

Removes duplicates from the funcmap that exist already in sprig.
Note that this does leave the `hasPrefix` function overriding the one in
sprig. This is because the sprig function expects arguments of the form
`(prefix, string)` and the existing go-swagger function expects
`(string, prefix)`.

As to not cause a breaking change to the existing templating this was
left as-is.

Signed-off-by: Kevin Barbour <kevinbarbourd@gmail.com>
@codecov
Copy link

codecov bot commented Mar 21, 2022

Codecov Report

Merging #2741 (5168aca) into master (b541a73) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2741      +/-   ##
==========================================
+ Coverage   82.77%   82.78%   +0.01%     
==========================================
  Files          55       55              
  Lines        9583     9587       +4     
==========================================
+ Hits         7932     7937       +5     
+ Misses       1130     1129       -1     
  Partials      521      521              
Impacted Files Coverage Δ
generator/template_repo.go 90.10% <100.00%> (+0.08%) ⬆️
generator/structs.go 84.35% <0.00%> (+0.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b541a73...5168aca. Read the comment docs.

@youyuanwu youyuanwu merged commit db2121b into go-swagger:master Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add trimPrefix and trimSuffix to template FuncMap
2 participants