-
Notifications
You must be signed in to change notification settings - Fork 72
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 lambdas for Go #85
Conversation
See mustache/spec#85 for how the tests were generated. If / when that pull request is merged, I will also update the submodule reference in this project. “Lambdas are a special-cased data type for use in interpolations and sections. “When used as the data value for an Interpolation tag, the lambda MUST be treatable as an arity 0 function, and invoked as such. The returned value MUST be rendered against the default delimiters, then interpolated in place of the lambda. When used as the data value for a Section tag, the lambda MUST be treatable as an arity 1 function, and invoked as such (passing a String containing the unprocessed section contents). The returned value MUST be rendered against the current delimiters, then interpolated in place of the section.”
How can I help this progress? |
@jabley I'm going to help you get this merged. Would you like to update your branch first? |
specs/~lambdas.yml
Outdated
@@ -75,6 +78,7 @@ tests: | |||
clojure: '(def g (atom 0)) (fn [] (swap! g inc))' | |||
lisp: '(let ((g 0)) (lambda () (incf g)))' | |||
pwsh: 'if (($null -eq $script:calls) -or ($script:calls -ge 3)){$script:calls=0}; ++$script:calls; $script:calls' | |||
go: 'func() func()(string) { g := 0; return func() string { g++; return strconv.Itoa(g); } } ()' |
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.
Why convert the integer to string? If possible, I would prefer that you declare that the function returns an integer.
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.
Requiring a string was a limitation of the mustache implementation that I originally wrote, but there's no reason to enforce that limitation, and I changed my version to happily handle other types.
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.
Thanks!
No description provided.