Right now I have something like this in my mustache template:
{{#render}}{{widget}}{{/render}}
And I have a viewModel which contains this code:
public function render() {
$View = $this->_View;
return function($widgetName, Mustache_LambdaHelper $helper) use (&$View) {
$widget = $helper->render($widgetName);
return $helper->render($View->mustache->getPartialsLoader()->load("$widget.view"));
};
}
I think you can see what I am trying to do here. I am trying to render a partial who's name is contained inside the widget-key of the current context.
Now the thing is, I really don't like the format I'm using in the template. I would prefer if I could write something like this:
{{renderWidget}}
then I would need to be able to access the current context directly in some way.
public function renderWidget() {
return function($context) {
return $helper->render($View->mustache->getPartialsLoader()->load("$context[widget].view"));
}
}
Can anybody tell me if that is possible in one way or another?