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

Make Mustache_LambdaHelper invokable #285

Closed
Svish opened this issue Feb 12, 2016 · 1 comment
Closed

Make Mustache_LambdaHelper invokable #285

Svish opened this issue Feb 12, 2016 · 1 comment

Comments

@Svish
Copy link

Svish commented Feb 12, 2016

Suggestion to make the Mustache_LambdaHelper class "invokable"? Would make lambda's and such a tiny bit cleaner, which I like, and very simple to do:

Added to Mustache_LambdaHelper

/**
 * Alias of render(string).
 */
public function __invoke($string)
{
    return $this->render($string);
}

Should be backwards compatible and works for PHP>=5.3. The wiki says the mustache code works for PHP>=5.2, but don't think this would break that. It just wouldn't be usable for that version.

Example usage

$engine->render('foobar', [
    'upper' => function($text, $render)
        {
            return strtoupper($render($text));
        },
    ]);
@bobthecow
Copy link
Owner

👍 This has been added to the dev branch and will go out in the next release.

bobthecow added a commit that referenced this issue Feb 14, 2016
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

No branches or pull requests

2 participants