<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage PluginsFilter
 * 
 * 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 affect
 *           <<PRE>></PRE> and <SCRIPT></SCRIPT> blocks.<br>
 * Install:  Drop into the plugin directory, call
 *           <code>$smarty->load_filter('output','trimwhitespacesimple');</code>
 *           from application.
 * 
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @author Contributions from Lars Noschinski <lars@usenet.noschinski.de>
 * @author Simple version by untermStrich
 * @version  1.3
 */

/**
 * Smarty trimwhitespace outputfilter plugin
 *
 * @param   string  $source     Input string
 * @param   object  $smarty     Smarty object
 * @return  string  Filtered output
 */
function smarty_outputfilter_trimwhitespacesimple($source, $smarty)
{
    return trim(preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source));
}

?>
