Skip to content

Instantly share code, notes, and snippets.

@irae
Last active January 3, 2016 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irae/8448024 to your computer and use it in GitHub Desktop.
Save irae/8448024 to your computer and use it in GitHub Desktop.
<?php
class __MyTemplates_114bca0f494f001129103063fc737167 extends Mustache_Template
{
protected $strictCallables = true;
public function renderInternal(Mustache_Context $context, $indent = '')
{
$buffer = '';
$buffer .= $indent . '<div class="test">
<h2>This is a test of ';
$value = $this->resolveValue($context->find('name'), $context, $indent);
$buffer .= htmlspecialchars($value, 2, 'UTF-8');
$buffer .= '</h2>
<p>The homepage is <a href="';
$value = $this->resolveValue($context->find('url'), $context, $indent);
$buffer .= htmlspecialchars($value, 2, 'UTF-8');
$buffer .= '">';
$value = $this->resolveValue($context->find('url'), $context, $indent);
$buffer .= htmlspecialchars($value, 2, 'UTF-8');
$buffer .= '</a>.</p>
<p>The sources is: ';
$value = $this->resolveValue($context->find('source'), $context, $indent);
$buffer .= htmlspecialchars($value, 2, 'UTF-8');
$buffer .= '</p>
</div>
';
return $buffer;
}
}
<?php
class __MyTemplates_412390a2c222edbc114ececf5bdc5fce extends Mustache_Template
{
private $lambdaHelper;
public function renderInternal(Mustache_Context $context, $indent = '')
{
$this->lambdaHelper = new Mustache_LambdaHelper($this->mustache, $context);
$buffer = '';
$buffer .= $indent . '<div class="comments">
<h3>';
$value = $this->resolveValue($context->find('header'), $context, $indent);
$buffer .= htmlspecialchars($value, 2, 'UTF-8');
$buffer .= '</h3>
<ul>
';
// 'comments' section
$value = $context->find('comments');
$buffer .= $this->sectionF366dc769fb785da783404452b0e6516($context, $indent, $value);
$buffer .= '
</ul>
</div>
';
return $buffer;
}
private function sectionF366dc769fb785da783404452b0e6516(Mustache_Context $context, $indent, $value)
{
$buffer = '';
if (!is_string($value) && is_callable($value)) {
$source = '
<li class="comment">
<h5>{{ name }}</h5>
<p>{{ body }}</p>
</li>
';
$result = call_user_func($value, $source, $this->lambdaHelper);
if (strpos($result, '{{') === false) {
$buffer .= $result;
} else {
$buffer .= $this->mustache
->loadLambda((string) $result)
->renderInternal($context);
}
} elseif (!empty($value)) {
$values = $this->isIterable($value) ? $value : array($value);
foreach ($values as $value) {
$context->push($value);
$buffer .= '
<li class="comment">
<h5>';
$value = $this->resolveValue($context->find('name'), $context, $indent);
$buffer .= htmlspecialchars($value, 2, 'UTF-8');
$buffer .= '</h5>
<p>';
$value = $this->resolveValue($context->find('body'), $context, $indent);
$buffer .= htmlspecialchars($value, 2, 'UTF-8');
$buffer .= '</p>
</li>
';
$context->pop();
}
}
return $buffer;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment