-
Notifications
You must be signed in to change notification settings - Fork 277
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
adds ability to define custom funcs in LocalizeConfig #99 #100
Conversation
Codecov Report
@@ Coverage Diff @@
## master #100 +/- ##
=======================================
Coverage 63.93% 63.93%
=======================================
Files 28 28
Lines 2271 2271
=======================================
Hits 1452 1452
Misses 745 745
Partials 74 74
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea, thanks!
v2/internal/template_test.go
Outdated
func TestParseWithFunc(t *testing.T) { | ||
tmpl := &Template{Src: "hello"} | ||
funcs := template.FuncMap{ | ||
"foo": func() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test doesn't seem to actually use the "foo" func. Can you add a test that does that?
forgot to change |
tmpl := &Template{Src: "{{foo}}"} | ||
funcs := template.FuncMap{ | ||
"foo": func() string { | ||
return "bar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also check that the value produced by the template is actually “bar”
there we go 👍 |
This PR adds the ability to define custom template engine funcs. It adds a
Funcs
field to theLocalizeConfig
struct and passes this parameter togotemplate.Funcs
.