Created
June 7, 2012 14:09
-
-
Save jbroadway/2889005 to your computer and use it in GitHub Desktop.
PHP cached template comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1><?php echo Template::sanitize ($data->title, 'UTF-8'); ?></h1> | |
<?php if ($data->show_people) { ?> | |
<ul> | |
<?php foreach ($data->people as $data->loop_index => $data->loop_value) { ?> | |
<li><?php echo Template::sanitize ($data->loop_value, 'UTF-8'); ?></li> | |
<?php } ?> | |
</ul> | |
<?php } ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>{{title}}</h1> | |
{% if show_people %} | |
<ul> | |
{% foreach people %} | |
<li>{{loop_value}}</li> | |
{% end %} | |
</ul> | |
{% end %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php /* Smarty version Smarty-3.1.8, created on 2012-06-07 13:10:13 | |
compiled from "apps/template-bench/views/smarty3.html" */ ?> | |
<?php /*%%SmartyHeaderCode:12503048704fd0a835ee8ac4-90054934%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed'); | |
$_valid = $_smarty_tpl->decodeProperties(array ( | |
'file_dependency' => | |
array ( | |
'84d0b1be7a90e37d9f5f579686f18a40d4474c1b' => | |
array ( | |
0 => 'apps/template-bench/views/smarty3.html', | |
1 => 1339074238, | |
2 => 'file', | |
), | |
), | |
'nocache_hash' => '12503048704fd0a835ee8ac4-90054934', | |
'function' => | |
array ( | |
), | |
'variables' => | |
array ( | |
'title' => 0, | |
'show_people' => 0, | |
'people' => 0, | |
'person' => 0, | |
), | |
'has_nocache_code' => false, | |
'version' => 'Smarty-3.1.8', | |
'unifunc' => 'content_4fd0a836016a36_28992089', | |
),false); /*/%%SmartyHeaderCode%%*/?> | |
<?php if ($_valid && !is_callable('content_4fd0a836016a36_28992089')) {function content_4fd0a836016a36_28992089($_smarty_tpl) {?><h1><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['title']->value, ENT_QUOTES, 'UTF-8', true);?> | |
</h1> | |
<?php if ($_smarty_tpl->tpl_vars['show_people']->value){?> | |
<ul> | |
<?php $_smarty_tpl->tpl_vars['person'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['person']->_loop = false; | |
$_from = $_smarty_tpl->tpl_vars['people']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');} | |
foreach ($_from as $_smarty_tpl->tpl_vars['person']->key => $_smarty_tpl->tpl_vars['person']->value){ | |
$_smarty_tpl->tpl_vars['person']->_loop = true; | |
?> | |
<li><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['person']->value, ENT_QUOTES, 'UTF-8', true);?> | |
</li> | |
<?php } ?> | |
</ul> | |
<?php }?> | |
<?php }} ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>{$title|escape}</h1> | |
{if $show_people} | |
<ul> | |
{foreach $people as $person} | |
<li>{$person|escape}</li> | |
{/foreach} | |
</ul> | |
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* twig.html */ | |
class __TwigTemplate_f6886b8cf5b4826aef6b67e59f0d56be extends Twig_Template | |
{ | |
public function __construct(Twig_Environment $env) | |
{ | |
parent::__construct($env); | |
$this->parent = false; | |
$this->blocks = array( | |
); | |
} | |
protected function doDisplay(array $context, array $blocks = array()) | |
{ | |
// line 1 | |
echo "<h1>"; | |
if (isset($context["title"])) { $_title_ = $context["title"]; } else { $_title_ = null; } | |
echo twig_escape_filter($this->env, $_title_, "html", null, true); | |
echo "</h1> | |
"; | |
// line 3 | |
if (isset($context["show_people"])) { $_show_people_ = $context["show_people"]; } else { $_show_people_ = null; } | |
if ($_show_people_) { | |
// line 4 | |
echo "\t<ul> | |
\t"; | |
// line 5 | |
if (isset($context["people"])) { $_people_ = $context["people"]; } else { $_people_ = null; } | |
$context['_parent'] = (array) $context; | |
$context['_seq'] = twig_ensure_traversable($_people_); | |
foreach ($context['_seq'] as $context["_key"] => $context["person"]) { | |
// line 6 | |
echo "\t\t<li>"; | |
if (isset($context["person"])) { $_person_ = $context["person"]; } else { $_person_ = null; } | |
echo twig_escape_filter($this->env, $_person_, "html", null, true); | |
echo "</li> | |
\t"; | |
} | |
$_parent = $context['_parent']; | |
unset($context['_seq'], $context['_iterated'], $context['_key'], $context['person'], $context['_parent'], $context['loop']); | |
$context = array_merge($_parent, array_intersect_key($context, $_parent)); | |
// line 8 | |
echo "\t</ul> | |
"; | |
} | |
} | |
public function getTemplateName() | |
{ | |
return "twig.html"; | |
} | |
public function isTraitable() | |
{ | |
return false; | |
} | |
public function getDebugInfo() | |
{ | |
return array ( 45 => 8, 35 => 6, 30 => 5, 27 => 4, 24 => 3, 17 => 1,); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>{{title}}</h1> | |
{% if show_people %} | |
<ul> | |
{% for person in people %} | |
<li>{{person}}</li> | |
{% endfor %} | |
</ul> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment