BUGFIX: Make SSTemplateParser work with empty templates

This commit is contained in:
Hamish Friedlander 2011-03-25 12:28:03 +13:00
parent ce5648a700
commit 5ca97c7099
2 changed files with 36 additions and 26 deletions

View File

@ -3904,6 +3904,10 @@ class SSTemplateParser extends Parser {
* @return mixed|string - The php that, when executed (via include or exec) will behave as per the template source
*/
static function compileString($string, $templateName = "", $includeDebuggingComments=false) {
if (!trim($string)) {
$code = '';
}
else {
// Construct a parser instance
$parser = new SSTemplateParser($string);
$parser->includeDebuggingComments = $includeDebuggingComments;
@ -3917,6 +3921,7 @@ class SSTemplateParser extends Parser {
// Get the result
$code = $result['php'];
}
// Include top level debugging comments if desired
if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {

View File

@ -892,6 +892,10 @@ class SSTemplateParser extends Parser {
* @return mixed|string - The php that, when executed (via include or exec) will behave as per the template source
*/
static function compileString($string, $templateName = "", $includeDebuggingComments=false) {
if (!trim($string)) {
$code = '';
}
else {
// Construct a parser instance
$parser = new SSTemplateParser($string);
$parser->includeDebuggingComments = $includeDebuggingComments;
@ -905,6 +909,7 @@ class SSTemplateParser extends Parser {
// Get the result
$code = $result['php'];
}
// Include top level debugging comments if desired
if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {