Rendering Mustache Block with external templates

眉间皱痕 提交于 2019-12-08 00:08:59

问题


I'm using Mustache 2.7.0 and trying to play with Blocks pragma for the first time.

Basically, I call basic.mustache

{{< layout }}
{{$ title}}{{page.meta.name}}{{/ title}}
{{/ layout }}

calling the block layout.mustache

<!DOCTYPE html>
<html>
    <head></head>
    <body>
        <h1>{{$ title}}test{{/ title}}</h1>
    </body>
</html>

I see the value of page.meta.name appear on the page, but not the tags written in layout.mustache.
Anyone have an idea why?

PHP

$mustache = new Mustache_Engine(array(
    'pragmas' => [Mustache_Engine::PRAGMA_BLOCKS],
    'loader' => new Mustache_Loader_FilesystemLoader('htdocs/templates'),
    'partials_loader' => new Mustache_Loader_FilesystemLoader('htdocs/templates/partials/')
));

$tpl = $mustache->loadTemplate('basic');
echo $tpl->render( $this );

回答1:


It seems that partials_loader are not compatibles with Pragma blocks.

Removing this line:

'partials_loader' => new Mustache_Loader_FilesystemLoader('htdocs/templates/partials/')

Solved my problem.



来源:https://stackoverflow.com/questions/27446987/rendering-mustache-block-with-external-templates

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