使用外部模板渲染胡子块 [英] Rendering Mustache Block with external templates
本文介绍了使用外部模板渲染胡子块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Mustache 2.7.0 ,并尝试第一次玩 Blocks pragma .
I'm using Mustache 2.7.0 and trying to play with Blocks pragma for the first time.
基本上,我称 basic.mustache
{{< layout }}
{{$ title}}{{page.meta.name}}{{/ title}}
{{/ layout }}
调用块 layout.mustache
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1>{{$ title}}test{{/ title}}</h1>
</body>
</html>
我看到 page.meta.name 的值出现在页面上,但 layout.mustache 中写的标签却没有.
有人知道为什么吗?
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 );
推荐答案
似乎partials_loader
与Pragma blocks
不兼容.
删除此行:
It seems that partials_loader
are not compatibles with Pragma blocks
.
Removing this line:
'partials_loader' => new Mustache_Loader_FilesystemLoader('htdocs/templates/partials/')
解决了我的问题.
这篇关于使用外部模板渲染胡子块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文