Skip to content
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

Merged
merged 1 commit into from
Oct 30, 2023
Merged

Add lambdas for Go #85

merged 1 commit into from
Oct 30, 2023

Conversation

jabley
Copy link
Contributor

@jabley jabley commented Jan 4, 2015

No description provided.

jabley added a commit to jabley/mustache that referenced this pull request Jan 4, 2015
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.”
@jabley
Copy link
Contributor Author

jabley commented May 18, 2016

How can I help this progress?

@jgonggrijp
Copy link
Member

@jabley I'm going to help you get this merged. Would you like to update your branch first?

@@ -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); } } ()'
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@jgonggrijp jgonggrijp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jgonggrijp jgonggrijp merged commit 59be9b2 into mustache:master Oct 30, 2023
@jabley jabley mentioned this pull request Oct 31, 2023
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.

2 participants