Sim*_*old 2 mustache mustache.php
我正在使用Mustache 2.7.0并尝试首次使用Blocks pragma.
基本上,我称之为basic.mustache
{{< layout }}
{{$ title}}{{page.meta.name}}{{/ title}}
{{/ layout }}
Run Code Online (Sandbox Code Playgroud)
调用块layout.mustache
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1>{{$ title}}test{{/ title}}</h1>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我看到page.meta.name的值出现在页面上,而不是layout.mustache中写的标签.
任何人都知道为什么?
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 );
Run Code Online (Sandbox Code Playgroud)
这似乎partials_loader是不兼容机用Pragma blocks.
删除此行:
'partials_loader' => new Mustache_Loader_FilesystemLoader('htdocs/templates/partials/')
Run Code Online (Sandbox Code Playgroud)
解决了我的问题.