问题
I'm having trouble finding decent docs on loading partials programmatically through Mustache.
I'm trying to load a login page with the form being a partial (it'll change depending on different user interactions).
PHP:
$m = new Mustache_Engine(array(
'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__) . '/views'),
'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__) . '/views/login/partials')
));
$params = array();
$partials = array(
'login_area' => 'login_form'
);
echo $m->render('login/login', $params, $partials);
Mustache:
<div id="login-area">
{{> login_area}}
</div>
As I understand it, the $partials
array should load my partial correctly.
However, I get no errors and nothing is displayed under {{> login_area}}
Is there a different way to do this?
来源:https://stackoverflow.com/questions/30036447/how-to-dynamically-load-partials-in-mustache-php