Source for file BaseTemplate.php
Documentation is available at BaseTemplate.php
- 1: <?php
- 3: /**
- 4: * Nette Framework
- 5: *
- 6: * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
- 7: *
- 8: * This source file is subject to the "Nette license" that is bundled
- 9: * with this package in the file license.txt.
- 10: *
- 11: * For more information please see http://nettephp.com
- 12: *
- 18: */
- 28: /**
- 29: * Template.
- 30: *
- 34: */
- 36: {
- 40: /** @var array of function(BaseTemplate $sender); Occurs before a template is compiled - implement to customize the filters */
- 57: /**
- 58: * Registers callback as template compile-time filter.
- 61: */
- 63: {
- 67: throw new InvalidArgumentException("Filter '$textual' is not " . ($able ? 'callable.' : 'valid PHP callback.'));
- 68: }
- 72: }
- 74: }
- 78: /**
- 79: * Returns all registered compile-time filters.
- 81: */
- 83: {
- 85: }
- 89: /********************* rendering ****************d*g**/
- 93: /**
- 94: * Renders template to output.
- 97: */
- 99: {
- 100: }
- 104: /**
- 105: * Renders template to string.
- 108: */
- 110: {
- 123: }
- 124: }
- 125: }
- 129: /**
- 130: * Applies filters on template content.
- 134: */
- 136: {
- 139: }
- 146: }
- 149: throw new InvalidStateException("Filter $textual: " . $e->getMessage() . ($label ? " (in $label)" : ''), 0, $e);
- 150: }
- 154: }
- 157: }
- 161: /********************* template helpers ****************d*g**/
- 165: /**
- 166: * Registers callback as template run-time helper.
- 170: */
- 172: {
- 176: throw new InvalidArgumentException("Helper handler '$textual' is not " . ($able ? 'callable.' : 'valid PHP callback.'));
- 177: }
- 179: }
- 183: /**
- 184: * Registers callback as template run-time helpers loader.
- 187: */
- 189: {
- 193: throw new InvalidArgumentException("Helper loader '$textual' is not " . ($able ? 'callable.' : 'valid PHP callback.'));
- 194: }
- 196: }
- 200: /**
- 201: * Returns all registered run-time helpers.
- 203: */
- 205: {
- 207: }
- 211: /**
- 212: * Call a template run-time helper. Do not call directly.
- 216: */
- 218: {
- 226: }
- 227: }
- 229: }
- 232: }
- 236: /**
- 237: * Sets translate adapter.
- 240: */
- 242: {
- 243: $this->registerHelper('translate', $translator === NULL ? NULL : array($translator, 'translate'));
- 245: }
- 249: /********************* template parameters ****************d*g**/
- 253: /**
- 254: * Adds new template parameter.
- 258: */
- 260: {
- 263: }
- 266: }
- 270: /**
- 271: * Sets all parameters.
- 274: */
- 276: {
- 279: }
- 283: /**
- 270: /**
- 271: * Returns array of all parameters.
- 286: */
- 288: {
- 290: }
- 294: /**
- 295: * Sets a template parameter. Do not call directly.
- 299: */
- 301: {
- 303: }
- 307: /**
- 308: * Returns a template parameter. Do not call directly.
- 311: */
- 313: {
- 316: }
- 319: }
- 323: /**
- 324: * Determines whether parameter is defined. Do not call directly.
- 327: */
- 329: {
- 331: }
- 335: /**
- 336: * Removes a template parameter. Do not call directly.
- 339: */
- 341: {
- 343: }
- 347: /********************* tools ****************d*g**/
- 351: /**
- 352: * Extracts all blocks of PHP code.
- 356: */
- 358: {
- 370: }
- 372: }
- 375: }
- 376: }
- 378: }
- 382: /**
- 383: * Removes unnecessary blocks of PHP code.
- 386: */
- 388: {
- 404: if ($lastChar !== ';' && $lastChar !== '{' && $lastChar !== '}' && $lastChar !== ':' && $lastChar !== '/' ) $php .= $lastChar = ';';
- 414: }
- 417: if ($tokens[$key + 1] === ':' && $lastChar === '}') $php .= ';'; // semicolon needed in if(): ... if() ... else:
- 424: }
- 427: }
- 428: }
- 430: }
- 432: }