static function instance() { if (self::$instance) { return self::$instance; } self::$instance = new lmbMacroTagDictionary(); return self::$instance; }
protected function _createCompiler() { lmb_require('limb/macro/src/compiler/*.interface.php'); lmb_require('limb/macro/src/compiler/*.class.php'); $tag_dictionary = lmbMacroTagDictionary::instance(); $filter_dictionary = lmbMacroFilterDictionary::instance(); $tag_dictionary->load($this->config); $filter_dictionary->load($this->config); return new lmbMacroCompiler($tag_dictionary, $this->locator, $filter_dictionary); }
{ // note that we overrided _generateContent since generate() methods pregenerates dynamic attributes function _generateContent($code) { $code->writePHP('echo ' . $this->getEscaped('attr') . ';'); } } $foo_info = new lmbMacroTagInfo('foo', 'MacroTagFooTest'); $foo_info->setFile(__FILE__); $bar_info = new lmbMacroTagInfo('bar', 'MacroTagBarTest'); $bar_info->setFile(__FILE__); $zoo_info = new lmbMacroTagInfo('zoo', 'MacroTagZooTest'); $zoo_info->setFile(__FILE__); lmbMacroTagDictionary::instance()->register($foo_info); lmbMacroTagDictionary::instance()->register($bar_info); lmbMacroTagDictionary::instance()->register($zoo_info); class lmbMacroTagAcceptanceTest extends lmbBaseMacroTest { function testTemplateRendering() { $code = '<h1>{{foo/}}{{bar/}}</h1>'; $tpl = $this->_createMacroTemplate($code, 'tpl.html'); $out = $tpl->render(); $this->assertEqual($out, '<h1>foo!bar</h1>'); } function testTagsInsideXmlBlock_WithOtherPhpBlockNearby() { $code = '<?xml version="1.0" encoding="utf-8" ?><h1><?php echo "hi!"; ?>{{foo/}}{{bar/}}</h1>'; $tpl = $this->_createMacroTemplate($code, 'tpl.html'); $out = $tpl->render(); $this->assertEqual($out, '<?xml version="1.0" encoding="utf-8" ?><h1>hi!foo!bar</h1>');