public function translate($template, $container = null) { $template = $this->_fixTemplateName($template); $template = $this->_templatePath . DIRECTORY_SEPARATOR . $template; if (!file_exists($template)) { throw new Exception('Missing template'); } $root = Engine_Template_Processor::process(file_get_contents($template)); $content = Engine_Template_Processor::toJavascript($root); //$root = Engine_Template_Token::fromString(file_get_contents($template)); //$content = $root->toJavascript(); // echo "<pre>"; // echo $root->outputDebug(); // die(); if (null === $container) { return $content; } else { return 'window["' . $container . '"] = function() {' . "\n" . $content . "\n" . '}'; } }
public static function toJavascript($node) { if ($node->getCode() == T_WLG_ROOT) { self::$_indentLevel = 0; } if ($node->getSkipRender()) { return ''; } $content = self::getJavascriptToken($node); if ($node->getSkipRender()) { return $content; } foreach ($node->getChildren() as $child) { $content .= self::toJavascript($child); } return $content; }