/** * Creates the PHP code for the given array of blocks. * * @param array $arBlocks Array of blocks, see getBlocks() * @param string $strTplName Template reference name * @param string $strPrefix Prefix to prepend before the code * * @return string PHP code */ function getCodeBlock($arBlocks, $strTplName, $strPrefix = '$tpl') { $nl = "\r\n"; $code = ''; foreach ($arBlocks as $arBlock) { if (count($arBlock['sub']) > 0) { $code .= HTML_Template_PHPLIB_Generator::getCodeBlock($arBlock['sub'], $strTplName, $strPrefix); } $code .= $strPrefix . "->setBlock('" . $strTplName . "','" . $arBlock['name'] . "', '" . $arBlock['name'] . "_ref');" . $nl; } return $code; }
public function testGetTemplateNameFromFilename() { $this->assertEquals('some', HTML_Template_PHPLIB_Generator::getTemplateNameFromFilename('some.tpl')); $this->assertEquals('order', HTML_Template_PHPLIB_Generator::getTemplateNameFromFilename('/path/to/templates/order.mail')); /* //does not work on unix $this->assertEquals( 'mytemplate', HTML_Template_PHPLIB_Generator::getTemplateNameFromFilename( 'C:\\mytemplate.ihtml' ) ); */ }
/** * Generates PHP code for the given template file * * @param array $args Command line arguments * * @return void */ function doGenerate($args) { if (count($args) == 0) { $this->dieHard("No template file given\n", 1); } $strFile = $args[0]; include_once 'HTML/Template/PHPLIB/Generator.php'; $strCode = HTML_Template_PHPLIB_Generator::getCodeBlockDefinition($strFile); $this->dieHard($strCode, 0); }