diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index eab53150d..fa7fcb9c3 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -1108,7 +1108,13 @@ class TemplateHandler return ''; } - return preg_replace_callback('@(?\$([a-z_][a-z0-9_]*)@i', function($matches) { + return '->{$__Context->' . $matches[1] . '}'; + }, $php); + + // Replace all other variables with Context attributes. + $php = preg_replace_callback('@(?|(?' . $matches[1]; } }, $php); + + return $php; } } diff --git a/tests/unit/classes/TemplateHandlerTest.php b/tests/unit/classes/TemplateHandlerTest.php index d2a4ba124..1bde836c5 100644 --- a/tests/unit/classes/TemplateHandlerTest.php +++ b/tests/unit/classes/TemplateHandlerTest.php @@ -315,6 +315,15 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test array( '{\RX_BASEDIR}', '?>' + ), + // Rhymix improvements: object attributes enclosed in curly braces + array( + '
{$foo->$bar[$bazz]}
', + '?>
foo->{$__Context->bar}[$__Context->bazz] ?>
' + ), + array( + '
', + "\n" . 'if($__Context->foo->{$__Context->bar}){ ?>
' ), // Rhymix autoescape array(