Cache a Smarty block function
Posted: Tue Jun 05, 2012 7:43 am
I use GeSHi as syntax highlighter. But GeSHi is very slow, so I want to cache my Smarty block function and not to call this function for every page visitor. How can I make Smarty to cache the result of my block function?
Code: Select all
<?php
require_once(dirname(__FILE__) .'/geshi/geshi.php');
function smarty_block_code($params, $content, &$smarty)
{
if (isset($content) && isset($params['lang'])) {
$geshi = new GeSHi($content, $params['lang']);
$geshi->enable_classes(true);
$geshi->enable_keyword_links(false);
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
return $geshi->parse_code();
}
}
?>