I'm trying to use the PHP implementation of Mustache to embed some html content in a template like this :
[mytemplate begin]
[html content]
[mytemplate end]
My html content is in a html file and when I try rendering it I have an error:
echo $template->render(array('content' => file_get_contents('content.html')));
Here's the error :
Fatal error: Maximum function nesting level of '100' reached, aborting! in C:\wamp\www\resume\application\mustache\src\Mustache\Engine.php on line 257
How can I insert it as html content ?
the section.mustache file ( I removed a huge part of the html code, there's just the essential)
<!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>
And the content.html file (Consider that there's is two other <section>
with just the same amount of code)
<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>
You are a bit lost in namings. Mustache is about to guess which template is to be included by it’s name. That said,
{{> section}}
includes section.mustache
. Since it appears in your section.mustache
, the engine tries to recursively insert it into itself. Which apparently leads to infinite loop, which is terminated at nesting level 100 with an error you received.
You should rename your content.html
into content.mustache
and include content:
{{> content}}
Hope it helps.