|
TYPO3 API
SVNRelease
|
00001 <?php 00002 00003 /* * 00004 * This script belongs to the FLOW3 package "Fluid". * 00005 * * 00006 * It is free software; you can redistribute it and/or modify it under * 00007 * the terms of the GNU Lesser General Public License as published by the * 00008 * Free Software Foundation, either version 3 of the License, or (at your * 00009 * option) any later version. * 00010 * * 00011 * This script is distributed in the hope that it will be useful, but * 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * 00013 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with the script. * 00018 * If not, see http://www.gnu.org/licenses/lgpl.html * 00019 * * 00020 * The TYPO3 project - inspiring people to share! * 00021 * */ 00022 00023 /** 00024 * Declares new variables which are aliases of other variables. 00025 * Takes a "map"-Parameter which is an associative array which defines the shorthand mapping. 00026 * 00027 * The variables are only declared inside the <f:alias>...</f:alias>-tag. After the 00028 * closing tag, all declared variables are removed again. 00029 * 00030 * = Examples = 00031 * 00032 * <code title="Single alias"> 00033 * <f:alias map="{x: 'foo'}">{x}</f:alias> 00034 * </code> 00035 * <output> 00036 * foo 00037 * </output> 00038 * 00039 * <code title="Multiple mappings"> 00040 * <f:alias map="{x: foo.bar.baz, y: foo.bar.baz.name}"> 00041 * {x.name} or {y} 00042 * </f:alias> 00043 * </code> 00044 * <output> 00045 * [name] or [name] 00046 * depending on {foo.bar.baz} 00047 * </output> 00048 * 00049 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later 00050 * @api 00051 */ 00052 class Tx_Fluid_ViewHelpers_AliasViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper { 00053 00054 /** 00055 * 00056 * @param array $map 00057 * @return string Rendered string 00058 * @author Bastian Waidelich <bastian@typo3.org> 00059 * @api 00060 */ 00061 public function render(array $map) { 00062 foreach ($map as $aliasName => $value) { 00063 $this->templateVariableContainer->add($aliasName, $value); 00064 } 00065 $output = $this->renderChildren(); 00066 foreach ($map as $aliasName => $value) { 00067 $this->templateVariableContainer->remove($aliasName); 00068 } 00069 return $output; 00070 } 00071 } 00072 00073 ?>
1.8.0