How to dynamically load partials in Mustache PHP?

痞子三分冷 提交于 2019-12-13 01:33:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!