【发布时间】:2015-01-18 16:38:24
【问题描述】:
我正在尝试使用 Mustache 的 PHP 实现将一些 html 内容嵌入到这样的模板中:
[mytemplate begin]
[html content]
[mytemplate end]
我的 html 内容在一个 html 文件中,当我尝试渲染它时出现错误:
echo $template->render(array('content' => file_get_contents('content.html')));
这是错误:
致命错误:已达到最大函数嵌套级别“100”,正在中止!在第 257 行的 C:\wamp\www\resume\application\mustache\src\Mustache\Engine.php 中
如何将其作为 html 内容插入?
section.mustache 文件(我删除了很大一部分 html 代码,这只是必不可少的)
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<!-- CONTENT -->
<div class="container">
{{> section}}
</div>
</body>
</html>
还有 content.html 文件(假设还有两个 <section> 代码量相同)
<div class="section">
<!-- Icon Section -->
<div class="row">
<div class="col s12 m8 offset-m2 l8 offset-l2">
<section id="sports" class="section scrollspy">
<h1>Sports</h1>
<div class="card">
<div class="card-image waves-effect waves-block waves-light">
<img src="media/images/climbing.jpg">
</div>
<div class="card-content">
<span class="card-title activator grey-text text-darken-4">Escalade<i class="mdi-navigation-more-vert right"></i></span>
</div>
<div class="card-reveal z-depth-3">
<span class="card-title grey-text text-darken-4"><h4>Escalade</h4><i class="mdi-navigation-close right"></i></span>
<p class="flow-text">Here is some more information about this product that is only revealed once clicked on. </p>
</div>
</div>
<div class="card">
<div class="card-image waves-effect waves-block waves-light">
<img src="media/images/snowboard.jpg">
</div>
<div class="card-content">
<span class="card-title activator grey-text text-darken-4">Snowboard<i class="mdi-navigation-more-vert right"></i></span>
</div>
<div class="card-reveal">
<span class="card-title grey-text text-darken-4"><h4>Snowboard</h4><i class="mdi-navigation-close right"></i></span>
<p class="flow-text">Here is some more information about this product that is only revealed once clicked on.</p>
</div>
</div>
</section>
</div>
<div class="col hide-on-small-only s12 m2 l1">
<div style="height: 1px;">
<ul class="section table-of-contents pinned" style="top: 0px;">
<li><a href="#sports" class="">Sports</a></li>
</ul>
</div>
</div>
</div>
</div>
【问题讨论】:
-
你能分享一下小胡子模板和
content.html吗? -
当然,刚刚做到了。这些是注释完整的代码,我只是把必要的
标签: php html mustache mustache.php