Source for file SnippetHelper.php
Documentation is available at SnippetHelper.php
6: * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
8: * This source file is subject to the "Nette license" that is bundled
9: * with this package in the file license.txt.
11: * For more information please see http://nettephp.com
13: * @copyright Copyright (c) 2004, 2009 David Grudl
14: * @license http://nettephp.com/license Nette license
15: * @link http://nettephp.com
17: * @package Nette\Templates
22: require_once dirname(__FILE__) .
'/../../Object.php';
27: * Control snippet template helper.
29: * @author David Grudl
30: * @copyright Copyright (c) 2004, 2009 David Grudl
31: * @package Nette\Templates
36: public static $outputAllowed =
TRUE;
44: /** @var ArrayObject */
53: * Starts conditional snippet rendering. Returns SnippetHelper object if snippet was started.
54: * @param Control control
55: * @param string snippet name
56: * @param string start element
57: * @return SnippetHelper
59: public static function create(Control $control, $name =
NULL, $tag =
'div')
61: if (self::$outputAllowed) { // rendering flow or non-AJAX request
64: if ($obj->tag) echo '<', $obj->tag, ' id="', $control->getSnippetId($name), '">';
65: return $obj; // or string?
67: } elseif ($control->isControlInvalid($name)) { // start snippet buffering
69: $obj->id =
$control->getSnippetId($name);
70: $obj->payload =
$control->getPresenter()->getPayload();
73: self::$outputAllowed =
TRUE;
84: * Finishes and saves the snippet.
89: if ($this->tag !==
NULL) { // rendering flow or non-AJAX request
90: if ($this->tag) echo "</$this->tag>";
92: } else { // finish snippet buffering
97: self::$outputAllowed =
FALSE;