Skip to content

Instantly share code, notes, and snippets.

@lukemorton
Created March 1, 2011 23:20
Show Gist options
  • Save lukemorton/850106 to your computer and use it in GitHub Desktop.
Save lukemorton/850106 to your computer and use it in GitHub Desktop.
Lambda example for Mustache.php
<?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