- // Check for either the end tag or the start of a macro expansion.
- else if ($delta >= 2) {
- $substr = substr($data, $i, 2);
- // Check for an end tag.
- if ($substr == '%}') {
- // If an end tag was encountered without an open tag, that's an error.
- if (!$looking_for_end) {
- $column = $i - $i_last_line;
- throw new TemplateException("Unexpected end of expansion at line $line_number:$column");
- }
-
- // If this is a macro, it's time to process it.
- if ($in_macro)
- $processed .= $this->_ProcessMacro($macro);
-
- $looking_for_end = FALSE;
- $in_macro = FALSE;
- $processed .= ' ?>';
- $i += 2;
- continue;
- }
- // Check for the beginning of a macro.
- else if ($substr == '{%') {
- // If an expansion has already been opened, then it's an error to nest.
- if ($looking_for_end) {
- $column = $i - $i_last_line;
- throw new TemplateException("Unexpected start of expansion at line $line_number:$column");
- }
-
- $processed .= '<' . '?php echo ';
- $macro = '';
- $in_macro = TRUE;
- $looking_for_end = TRUE;
- $i += 2;
- continue;
+ // Check for the close tag.
+ else if ($delta >= $close_tag_len &&
+ substr($data, $i, $close_tag_len) == self::$close_tag) {
+ // If an end tag was encountered without an open tag, that's an error.
+ if (!$looking_for_end) {
+ $column = $i - $i_last_line;
+ throw new TemplateException("Unexpected end of expansion at line $line_number:$column");