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);
 }
    function testLoad()
    {
        $rnd = mt_rand();
        $content1 = <<<EOD
<?php
/**
 * @tag foo_{$rnd}
 */
class Foo{$rnd}Tag extends lmbMacroTag{}
EOD;
        $content2 = <<<EOD
<?php
/**
 * @tag bar_{$rnd}
 */
class Bar{$rnd}Tag extends lmbMacroTag{}
EOD;
        file_put_contents($file1 = LIMB_VAR_DIR . '/tpl/tags/foo_' . $rnd . '.tag.php', $content1);
        file_put_contents($file2 = LIMB_VAR_DIR . '/tpl/tags/subfolder/bar_' . $rnd . '.tag.php', $content2);
        $tag_info1 = new lmbMacroTagInfo("foo_{$rnd}", "Foo{$rnd}Tag");
        $tag_info1->setFile($file1);
        $tag_info2 = new lmbMacroTagInfo("bar_{$rnd}", "Bar{$rnd}Tag");
        $tag_info2->setFile($file2);
        $config = $this->_createMacroConfig();
        $config->tags_scan_dirs = array(LIMB_VAR_DIR . '/tpl/tags/');
        $dictionary = new lmbMacroTagDictionary();
        $dictionary->load($config);
        $this->assertEqual($dictionary->findTagInfo("foo_{$rnd}")->getTag(), $tag_info1->getTag());
        $this->assertEqual($dictionary->findTagInfo("bar_{$rnd}")->getTag(), $tag_info2->getTag());
    }
{
    // 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>');