Changeset 2481 for trunk/include/template.class.php
- Timestamp:
- Aug 22, 2008, 2:45:03 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/template.class.php
r2476 r2481 80 80 $this->smarty->register_modifier( 'explode', array('Template', 'mod_explode') ); 81 81 $this->smarty->register_block('html_head', array(&$this, 'block_html_head') ); 82 $this->smarty->register_prefilter( array('Template', 'prefilter_white_space') ); 82 83 if ( $conf['compiled_template_cache_language'] ) 83 84 { 84 $this->smarty->register_prefilter( array( &$this, 'prefilter_language') );85 $this->smarty->register_prefilter( array('Template', 'prefilter_language') ); 85 86 } 86 87 … … 356 357 } 357 358 359 /*static */ function prefilter_white_space($source, &$smarty) 360 { 361 $ld = $smarty->left_delimiter; 362 $rd = $smarty->right_delimiter; 363 $ldq = preg_quote($ld, '#'); 364 $rdq = preg_quote($rd, '#'); 365 366 $regex = array(); 367 $tags = array('if', 'foreach', 'section'); 368 foreach($tags as $tag) 369 { 370 array_push($regex, "#^\s+($ldq$tag"."[^$ld$rd]*$rdq)\s*$#m"); 371 array_push($regex, "#^\s+($ldq/$tag$rdq)\s*$#m"); 372 } 373 $tags = array('include', 'else', 'html_head'); 374 foreach($tags as $tag) 375 { 376 array_push($regex, "#^\s+($ldq$tag"."[^$ld$rd]*$rdq)\s*$#m"); 377 } 378 $source = preg_replace( $regex, "$1", $source); 379 return $source; 380 } 381 358 382 /** 359 383 * Smarty prefilter to allow caching (whenever possible) language strings 360 384 * from templates. 361 385 */ 362 function prefilter_language($source, &$smarty)386 /*static */ function prefilter_language($source, &$smarty) 363 387 { 364 388 global $lang; 365 $ldq = preg_quote($ this->smarty->left_delimiter, '~');366 $rdq = preg_quote($ this->smarty->right_delimiter, '~');389 $ldq = preg_quote($smarty->left_delimiter, '~'); 390 $rdq = preg_quote($smarty->right_delimiter, '~'); 367 391 368 392 $regex = "~$ldq *\'([^'$]+)\'\|@translate *$rdq~";
Note: See TracChangeset
for help on using the changeset viewer.