Skip to content

Instantly share code, notes, and snippets.

@j
Created June 16, 2011 21:16
Show Gist options
  • Save j/1030308 to your computer and use it in GitHub Desktop.
Save j/1030308 to your computer and use it in GitHub Desktop.
# header content stored in database
<div id="wrapper">
<div id="header"></div>
# body content stored in database
<div id="form-content">
<div id="creativebody" style="padding-top: 0 !important; padding-left: 32px; padding-right: 32px; margin-bottom: 20px">
<div id="offers">
<div class="offer">
{php} echo 'Hello!'; {/php}
{php}
$array = array(1,2,3,4,5);
foreach ($array as $value) {
echo $value . "<br>";
}
{/php}
</div>
</div>
</div>
</div>
<div class="clear"></div>
<a href="{{ redirectUrl }}" id="click-now" target="_blank"><div id="footergraphic"></div></a>
# footer content stored in database
<div style="font-size: 12px; margin: 10px 0; text-align: center">
The third-party product names, logos, brands, and trademarks shown on this website are the property of their respective owners. These companies are not affiliated with ________________.
</div>
<div id="footer" style="padding-top: 0;">
<a target="_blank" class="footer" href="/privacy.php">Privacy Policy</a>
</div>
</div>
<?php
namespace JStout\MainBundle\Component\Twig\Extension;
use Twig_Extension,
Twig_Filter_Method,
Twig_Environment;
class Parser extends Twig_Extension
{
public function getFilters()
{
return array(
'allow_php' => new Twig_Filter_Method($this, 'twig_allow_php_filter', array('needs_environment' => true)),
);
}
function twig_allow_php_filter(Twig_Environment $env, $value, $startTag = '<?php', $endTag = '?>')
{
if (false !== strpos($value, $startTag)) {
if ($startTag !== '<?php' && $endTag !== '?>') {
$value = preg_replace('/'.str_replace('/', '\\/', $startTag).'(.*?)'.str_replace('/', '\\/', $endTag).'/s', '<?php $1 ?>' , $value);
}
eval('?>' . $value . '<?php');
return '';
}
return $value;
}
public function getName()
{
return 'parser';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment