/** * compile TALES expression according to current talesMode * @return string with PHP code */ private function compileTalesToPHPExpression($expression) { if ($this->getTalesMode() === 'php') { return PHPTAL_Php_TalesInternal::php($expression); } return PHPTAL_Php_TalesInternal::compileToPHPExpression($expression, false); }
/** * returns PHP code that generates given string, including dynamic replacements */ public function interpolateTalesVarsInString($string) { if ($this->_talesMode == 'tales') { return PHPTAL_Php_TalesInternal::string($string); } // replace ${var} found in expression while (preg_match('/(?<!\\$)\\$\\{([^\\}]+)\\}/s', $string, $m)) { list($ori, $exp) = $m; $php = PHPTAL_Php_TalesInternal::php($exp); $string = str_replace($ori, '\'.' . $php . '.\'', $string); // FIXME: that is not elegant } $string = str_replace('$${', '${', $string); // FIXME: that is not elegant return '\'' . $string . '\''; }