Source for file SnippetHelper.php
Documentation is available at SnippetHelper.php
6: * @copyright Copyright (c) 2004, 2010 David Grudl
7: * @license http://nettephp.com/license Nette license
8: * @link http://nettephp.com
10: * @package Nette\Templates
16: * Control snippet template helper.
18: * @copyright Copyright (c) 2004, 2010 David Grudl
19: * @package Nette\Templates
24: public static $outputAllowed =
TRUE;
32: /** @var ArrayObject */
41: * Starts conditional snippet rendering. Returns SnippetHelper object if snippet was started.
42: * @param Control control
43: * @param string snippet name
44: * @param string start element
45: * @return SnippetHelper
47: public static function create(Control $control, $name =
NULL, $tag =
'div')
49: if (self::$outputAllowed) { // rendering flow or non-AJAX request
52: if ($obj->tag) echo '<', $obj->tag, ' id="', $control->getSnippetId($name), '">';
53: return $obj; // or string?
55: } elseif ($control->isControlInvalid($name)) { // start snippet buffering
57: $obj->id =
$control->getSnippetId($name);
58: $obj->payload =
$control->getPresenter()->getPayload();
61: self::$outputAllowed =
TRUE;
72: * Finishes and saves the snippet.
77: if ($this->tag !==
NULL) { // rendering flow or non-AJAX request
78: if ($this->tag) echo "</$this->tag>";
80: } else { // finish snippet buffering
85: self::$outputAllowed =
FALSE;