Created
March 1, 2011 23:20
-
-
Save lukemorton/850106 to your computer and use it in GitHub Desktop.
Lambda example for Mustache.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once('Mustache.php'); // Ensure feature/higher-order-sections branch !! | |
class MyMustache extends Mustache { | |
public function name() | |
{ | |
return "Luke"; | |
} | |
public function lambda() | |
{ | |
$view = $this; | |
return function ($block) use ($view) | |
{ | |
return '<strong>'.$view->render($block).'</strong>'; | |
}; | |
} | |
} | |
$m = new Mustache; | |
echo $m->render( | |
"{{#lambda}}{{name}}{{/lambda}}", | |
new MyMustache | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment