mirror of
https://github.com/smarty-php/smarty.git
synced 2026-05-05 12:14:12 +02:00
move strip processing from parser to compiler
This commit is contained in:
@@ -218,6 +218,13 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
*/
|
||||
public $parent_compiler = null;
|
||||
|
||||
/**
|
||||
* Strip preg pattern
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $stripRegEx = '![\t ]*[\r\n]+[\t ]*!';
|
||||
|
||||
/**
|
||||
* method to compile a Smarty template
|
||||
*
|
||||
@@ -595,6 +602,27 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
return '$_smarty_tpl->tpl_vars[' . $variable . ']->value';
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from parser to process a text content section
|
||||
* - remove text from inheritance child templates as they may generate output
|
||||
* - strip text if strip is enabled
|
||||
*
|
||||
* @param string $text
|
||||
*
|
||||
* @return null|\Smarty_Internal_ParseTree_Text
|
||||
*/
|
||||
public function processText($text) {
|
||||
if ($this->inheritance_child && !$this->blockTagNestingLevel) {
|
||||
return null;
|
||||
}
|
||||
if ($this->parser->strip) {
|
||||
return new Smarty_Internal_ParseTree_Text($this->parser, preg_replace($this->stripRegEx, '', $text));
|
||||
} else {
|
||||
return new Smarty_Internal_ParseTree_Text($this->parser, $text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* lazy loads internal compile plugin for tag and calls the compile method
|
||||
* compile objects cached for reuse.
|
||||
|
||||
Reference in New Issue
Block a user