[limb-svn] r6909 - in 3.x/trunk/limb/macro: src/compiler src/tags/core tests/cases/tags/core

svn at limb-project.com svn at limb-project.com
Thu Apr 10 12:27:26 MSD 2008


Author: serega
Date: 2008-04-10 12:27:26 +0400 (Thu, 10 Apr 2008)
New Revision: 6909
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6909

Modified:
   3.x/trunk/limb/macro/src/compiler/lmbMacroTagParsingState.class.php
   3.x/trunk/limb/macro/src/tags/core/insert.tag.php
   3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroInsertTagTest.class.php
Log:
-- {{insert}} tag now throws an exception in case of using "inline" attribute for a dynamic case
-- lmbMacroTagParsingState now display the line number and the file name in case if unknown tag was found.

Modified: 3.x/trunk/limb/macro/src/compiler/lmbMacroTagParsingState.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/compiler/lmbMacroTagParsingState.class.php	2008-04-10 07:33:05 UTC (rev 6908)
+++ 3.x/trunk/limb/macro/src/compiler/lmbMacroTagParsingState.class.php	2008-04-10 08:27:26 UTC (rev 6909)
@@ -22,6 +22,14 @@
     parent :: __construct($parser, $tree_builder);
     $this->tag_dictionary = $tag_dictionary;
   }
+  
+  function raiseNotSuchTagException($tag, $location)
+  {
+    $params = array('file', $location->getFile(),
+                    'line', $location->getLine());
+    
+    throw new lmbMacroException("Tag '$tag' not found in dictionary", $params);
+  }
 
   function startElement($tag, $attrs)
   {
@@ -30,7 +38,7 @@
     $lower_attributes = $this->normalizeAttributes($attrs, $location);
 
     if(!$tag_info = $this->tag_dictionary->findTagInfo($tag))
-      throw new lmbMacroException("Tag '$tag' not found in dictionary");
+      $this->raiseNotSuchTagException($tag, $location);
 
     if($tag_info->isEndTagForbidden())
     {
@@ -50,7 +58,7 @@
   function endElement($tag)
   {
     if(!$tag_info = $this->tag_dictionary->findTagInfo($tag))
-      throw new lmbMacroException("Tag '$tag' not found in dictionary");
+      $this->raiseNotSuchTagException($tag, $location);
     
     $location = $this->parser->getCurrentLocation();
 
@@ -72,7 +80,7 @@
     $lower_attributes = $this->normalizeAttributes($attrs, $location);
 
     if(!$tag_info = $this->tag_dictionary->findTagInfo($tag))
-      throw new lmbMacroException("Tag '$tag' not found in dictionary");
+      $this->raiseNotSuchTagException($tag, $location);
     $tag_info->load();
 
     $tag_node = $this->buildTagNode($tag_info, $tag, $attrs);

Modified: 3.x/trunk/limb/macro/src/tags/core/insert.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/insert.tag.php	2008-04-10 07:33:05 UTC (rev 6908)
+++ 3.x/trunk/limb/macro/src/tags/core/insert.tag.php	2008-04-10 08:27:26 UTC (rev 6909)
@@ -86,6 +86,9 @@
   {
     $handlers_str = 'array(';
     $methods = array();
+    
+    if($this->getBool('inline'))
+      $this->raise('Inline is not supported for dynamic case');      
 
     //collecting {{into}} tags
     if($intos = $this->_collectIntos())

Modified: 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroInsertTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroInsertTagTest.class.php	2008-04-10 07:33:05 UTC (rev 6908)
+++ 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroInsertTagTest.class.php	2008-04-10 08:27:26 UTC (rev 6909)
@@ -316,6 +316,27 @@
     $this->assertEqual($out, '<body><p>Number: 2</p></body>');
   }
 
+  function testDynamicInlineIncludeThrowsException()
+  {
+    $bar = '<body><?php $var2=2;?>{{insert file="$#foo" inline="true"/}}</body>';
+    $foo = '<p>Number: <?php echo $var2;?></p>';
+
+    $bar_tpl = $this->_createTemplate($bar, 'bar.html');
+    $foo_tpl = $this->_createTemplate($foo, 'foo.html');
+
+    $macro = $this->_createMacro($bar_tpl);
+    $macro->set('foo', "foo.html");
+
+    try
+    {
+      $out = $macro->render();
+      $this->assertTrue(false);
+    }
+    catch(lmbMacroException $e)
+    {
+    }
+  }
+  
   function testStaticIncludeMixLocalAndTemplateVariables()
   {
     $bar = '<body><?php $var2=2;?>{{insert file="foo.html" var1="1" var2="$var2"/}}</body>';



More information about the limb-svn mailing list