[limb-svn] r6955 - in 3.x/trunk/limb/macro: src/tags/core tests/cases/tags/core
svn at limb-project.com
svn at limb-project.com
Fri Apr 25 11:18:18 MSD 2008
Author: serega
Date: 2008-04-25 11:18:18 +0400 (Fri, 25 Apr 2008)
New Revision: 6955
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6955
Added:
3.x/trunk/limb/macro/src/tags/core/copy.tag.php
3.x/trunk/limb/macro/src/tags/core/cut.tag.php
3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroCopyAndCutTagsTest.class.php
Removed:
3.x/trunk/limb/macro/src/tags/core/buffer.tag.php
3.x/trunk/limb/macro/src/tags/core/paste.tag.php
3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroBufferAndPasteTagsTest.class.php
Log:
-- {{paste}} tag removed. Template writers should use regular output expressions instead.
-- {{buffer}} tag renamed to {{cut}}. The "into" attribute of {{cut}} tag should name a variable where captured output will be placed. e.g. {{cut into="$#my_buffer"}}...{{/cut}}
-- new {{copy}} tag added. The usage is like of {{cut}} tag but {{copy}} tag does flush captured output unlike {{cut}} tag.
Deleted: 3.x/trunk/limb/macro/src/tags/core/buffer.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/buffer.tag.php 2008-04-24 12:28:58 UTC (rev 6954)
+++ 3.x/trunk/limb/macro/src/tags/core/buffer.tag.php 2008-04-25 07:18:18 UTC (rev 6955)
@@ -1,24 +0,0 @@
-<?php
-/**
- * class lmbMacroBufferTag.
- * @tag buffer
- * @req_attributes into
- * @restrict_self_nesting
- */
-class lmbMacroBufferTag extends lmbMacroTag
-{
- protected function _generateContent($code)
- {
- $buffer_var = self :: generatBufferVar($this->get('into'));
-
- $code->writePHP("ob_start();\n");
- parent :: _generateContent($code);
- $code->writePHP("{$buffer_var} = ob_get_contents();\n");
- $code->writePHP("ob_end_clean();\n");
- }
-
- static function generatBufferVar($buffer_name)
- {
- return '$this->'. $buffer_name . '_temp_buffer';
- }
-}
Added: 3.x/trunk/limb/macro/src/tags/core/copy.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/copy.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/core/copy.tag.php 2008-04-25 07:18:18 UTC (rev 6955)
@@ -0,0 +1,17 @@
+<?php
+/**
+ * class lmbMacroCopyTag.
+ * @tag copy
+ * @req_attributes into
+ * @restrict_self_nesting
+ */
+class lmbMacroCopyTag extends lmbMacroTag
+{
+ protected function _generateContent($code)
+ {
+ $code->writePHP("ob_start();\n");
+ parent :: _generateContent($code);
+ $code->writePHP($this->get('into') . " = ob_get_contents();\n");
+ $code->writePHP("ob_end_flush();\n");
+ }
+}
Copied: 3.x/trunk/limb/macro/src/tags/core/cut.tag.php (from rev 6954, 3.x/trunk/limb/macro/src/tags/core/buffer.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/cut.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/core/cut.tag.php 2008-04-25 07:18:18 UTC (rev 6955)
@@ -0,0 +1,17 @@
+<?php
+/**
+ * class lmbMacroCutTag.
+ * @tag cut
+ * @req_attributes into
+ * @restrict_self_nesting
+ */
+class lmbMacroCutTag extends lmbMacroTag
+{
+ protected function _generateContent($code)
+ {
+ $code->writePHP("ob_start();\n");
+ parent :: _generateContent($code);
+ $code->writePHP($this->get('into') . " = ob_get_contents();\n");
+ $code->writePHP("ob_end_clean();\n");
+ }
+}
Deleted: 3.x/trunk/limb/macro/src/tags/core/paste.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/paste.tag.php 2008-04-24 12:28:58 UTC (rev 6954)
+++ 3.x/trunk/limb/macro/src/tags/core/paste.tag.php 2008-04-25 07:18:18 UTC (rev 6955)
@@ -1,18 +0,0 @@
-<?php
-lmb_require('limb/macro/src/tags/core/buffer.tag.php');
-/**
- * class lmbMacroPasteTag.
- * @tag paste
- * @req_attributes from
- * @forbid_end_tag
- */
-
-class lmbMacroPasteTag extends lmbMacroTag
-{
- protected function _generateContent($code)
- {
- $buffer_var = lmbMacroBufferTag :: generatBufferVar($this->get('from'));
-
- $code->writePHP("echo {$buffer_var};\n");
- }
-}
Deleted: 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroBufferAndPasteTagsTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroBufferAndPasteTagsTest.class.php 2008-04-24 12:28:58 UTC (rev 6954)
+++ 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroBufferAndPasteTagsTest.class.php 2008-04-25 07:18:18 UTC (rev 6955)
@@ -1,21 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-class lmbMacroBufferAndPasteTagsTest extends lmbBaseMacroTest
-{
- function testCopyAndPasteFromBuffer()
- {
- $template = '{{buffer into="my_buffer"}}F{{/buffer}}N|{{paste from="my_buffer"}}|{{paste from="my_buffer"}}';
-
- $page = $this->_createMacroTemplate($template, 'tpl.html');
-
- $this->assertEqual($page->render(), 'N|F|F');
- }
-}
-
Copied: 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroCopyAndCutTagsTest.class.php (from rev 6954, 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroBufferAndPasteTagsTest.class.php)
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroCopyAndCutTagsTest.class.php (rev 0)
+++ 3.x/trunk/limb/macro/tests/cases/tags/core/lmbMacroCopyAndCutTagsTest.class.php 2008-04-25 07:18:18 UTC (rev 6955)
@@ -0,0 +1,30 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+class lmbMacroCopyAndCutTagsTest extends lmbBaseMacroTest
+{
+ function testCopyTag()
+ {
+ $template = '{{copy into="$#my_buffer"}}F|{{/copy}}N|{$#my_buffer}';
+
+ $page = $this->_createMacroTemplate($template, 'tpl.html');
+
+ $this->assertEqual($page->render(), 'F|N|F|');
+ }
+
+ function testCutTag()
+ {
+ $template = '{{cut into="$#my_buffer"}}F|{{/cut}}N|{$#my_buffer}';
+
+ $page = $this->_createMacroTemplate($template, 'tpl.html');
+
+ $this->assertEqual($page->render(), 'N|F|');
+ }
+}
+
More information about the limb-svn
mailing list