本文整理汇总了PHP中smarty_outputfilter_trimwhitespace_replace函数的典型用法代码示例。如果您正苦于以下问题:PHP smarty_outputfilter_trimwhitespace_replace函数的具体用法?PHP smarty_outputfilter_trimwhitespace_replace怎么用?PHP smarty_outputfilter_trimwhitespace_replace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了smarty_outputfilter_trimwhitespace_replace函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_outputfilter_trimwhitespace
/**
* Smarty trimwhitespace outputfilter plugin
*
* File: outputfilter.trimwhitespace.php<br>
* Type: outputfilter<br>
* Name: trimwhitespace<br>
* Date: Jan 25, 2003<br>
* Purpose: trim leading white space and blank lines from
* template source after it gets interpreted, cleaning
* up code and saving bandwidth. Does not affect
* <<PRE>></PRE> and <SCRIPT></SCRIPT> blocks.<br>
* Install: Drop into the plugin directory, call
* <code>$smarty->load_filter('output','trimwhitespace');</code>
* from application.
* @author Monte Ohrt <monte at ohrt dot com>
* @author Contributions from Lars Noschinski <lars@usenet.noschinski.de>
* @version 1.3
* @param string $source input string
* @param object &$smarty Smarty object
* @return string filtered output
*/
function smarty_outputfilter_trimwhitespace($source, $smarty)
{
// Pull out the script blocks
preg_match_all("!<script[^>]*?>.*?</script>!is", $source, $match);
$_script_blocks = $match[0];
$source = preg_replace("!<script[^>]*?>.*?</script>!is", '@@@SMARTY:TRIM:SCRIPT@@@', $source);
// Pull out the pre blocks
preg_match_all("!<pre[^>]*?>.*?</pre>!is", $source, $match);
$_pre_blocks = $match[0];
$source = preg_replace("!<pre[^>]*?>.*?</pre>!is", '@@@SMARTY:TRIM:PRE@@@', $source);
// Pull out the textarea blocks
preg_match_all("!<textarea[^>]*?>.*?</textarea>!is", $source, $match);
$_textarea_blocks = $match[0];
$source = preg_replace("!<textarea[^>]*?>.*?</textarea>!is", '@@@SMARTY:TRIM:TEXTAREA@@@', $source);
// remove all leading spaces, tabs and carriage returns NOT
// preceeded by a php close tag.
$source = trim(preg_replace('/((?<!\\?>)\\n)[\\s]+/m', '\\1', $source));
// replace textarea blocks
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@", $_textarea_blocks, $source);
// replace pre blocks
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@", $_pre_blocks, $source);
// replace script blocks
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@", $_script_blocks, $source);
return $source;
}
示例2: smarty_outputfilter_trimwhitespace
function smarty_outputfilter_trimwhitespace($source,&$smarty)
{
preg_match_all("!<script[^>]*?>.*?</script>!is",$source,$match);
$_script_blocks = $match[0];
$source = preg_replace("!<script[^>]*?>.*?</script>!is",
'@@@SMARTY:TRIM:SCRIPT@@@',$source);
preg_match_all("!<pre[^>]*?>.*?</pre>!is",$source,$match);
$_pre_blocks = $match[0];
$source = preg_replace("!<pre[^>]*?>.*?</pre>!is",
'@@@SMARTY:TRIM:PRE@@@',$source);
preg_match_all("!<textarea[^>]*?>.*?</textarea>!is",$source,$match);
$_textarea_blocks = $match[0];
$source = preg_replace("!<textarea[^>]*?>.*?</textarea>!is",
'@@@SMARTY:TRIM:TEXTAREA@@@',$source);
$source = trim(preg_replace('/((?<!\?>)\n)[\s]+/m','\1',$source));
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks,$source);
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks,$source);
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks,$source);
return $source;
}
示例3: smarty_outputfilter_html_minify
/**
* Smarty html_minify outputfilter plugin
*
* File: outputfilter.html_minify.php<br>
* Type: outputfilter<br>
* Name: html_minify<br>
* Date: Feb 06, 2011<br>
* Purpose: it minifies html yo!
* Install: Drop into the plugin directory, call
* <code>$smarty->load_filter('output','html_minify');</code>
* from application.
* @author Nicholas Granado <ngranado at gmail dot com>
* @author Based on outputfilter.trimwhitespace from Monte Ohrt <monte at ohrt dot com>
* @author Contributions from Lars Noschinski <lars@usenet.noschinski.de>
* @version 1.0
* @param string
* @param Smarty
*/
function smarty_outputfilter_html_minify($source, &$smarty)
{
// Pull out the script blocks
preg_match_all("!<script[^>]*?>.*?</script>!is", $source, $match);
$_script_blocks = $match[0];
$source = preg_replace("!<script[^>]*?>.*?</script>!is", '@@@SMARTY:TRIM:SCRIPT@@@', $source);
// Pull out the pre blocks
preg_match_all("!<pre[^>]*?>.*?</pre>!is", $source, $match);
$_pre_blocks = $match[0];
$source = preg_replace("!<pre[^>]*?>.*?</pre>!is", '@@@SMARTY:TRIM:PRE@@@', $source);
// Pull out the textarea blocks
preg_match_all("!<textarea[^>]*?>.*?</textarea>!is", $source, $match);
$_textarea_blocks = $match[0];
$source = preg_replace("!<textarea[^>]*?>.*?</textarea>!is", '@@@SMARTY:TRIM:TEXTAREA@@@', $source);
// remove all leading spaces, tabs and carriage returns NOT
// preceeded by a php close tag.
$source = trim(preg_replace('/((?<!\\?>)\\n)[\\s]+/m', '\\1', $source));
//---------- FROM HTML MINIFY
// remove HTML comments (not containing IE conditional comments).
$source = preg_replace_callback('/<!--([\\s\\S]*?)-->/', "_commentCB", $source);
// trim each line.
// @todo take into account attribute values that span multiple lines.
$source = preg_replace('/^\\s+|\\s+$/m', '', $source);
// remove ws around block/undisplayed elements
$source = preg_replace('/\\s+(<\\/?(?:area|base(?:font)?|blockquote|body' . '|caption|center|cite|col(?:group)?|dd|dir|div|dl|dt|fieldset|form' . '|frame(?:set)?|h[1-6]|head|hr|html|legend|li|link|map|menu|meta' . '|ol|opt(?:group|ion)|p|param|t(?:able|body|head|d|h||r|foot|itle)' . '|ul)\\b[^>]*>)/i', '$1', $source);
// remove ws outside of all elements
$source = preg_replace_callback('/>([^<]+)</', "_outsideTagCB", $source);
// use newlines before 1st attribute in open tags (to limit line lengths)
//$source = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $source);
//---------- END HTML MINIFY
// replace textarea blocks
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@", $_textarea_blocks, $source);
// replace pre blocks
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@", $_pre_blocks, $source);
// replace script blocks
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@", $_script_blocks, $source);
return $source;
}