Class Smarty_Compiler_Switch
Switch statement plugin for smarty. This smarty plugin provides php switch statement functionality in smarty tags. To install this plugin drop it into your smarty plugins folder. You will also need to manually load the plugin sot hat all the hooks are registered properly. Add the following line after you load smarty and create an instance of it in your source code.
$this->smartyObj->loadPlugin('smarty_compiler_switch');
- Smarty_Internal_CompileBase
- Smarty_Compiler_Switch
Author:
Jeremy Pyne jeremy.pyne@gmail.com - Donations: Accepted via PayPal at the above address. - Updated: 01/25/2016 - Version 3.7 - File: smarty/plugins/compiler.switch.php - Licence: CC:BY/NC/SA http://creativecommons.org/licenses/by-nc-sa/3.0/
Updates Version 2: Changed the break attribute to cause a break to be printed before the next case, instead of before this case. This way makes more sense and simplifies the code. This change in incompatible with code in from version one. This is written to support nested switches and will work as expected. Version 2.1: Added {/case} tag, this is identical to {break}. Version 3: Updated switch statment to support Smarty 3. This update is NOT backwards compatible but the old version is still maintained. Version 3.1: Added a prefilter to re-enable the shorthand {switch $myvar} support. To use the shorthand form you will need to add the following line to your code. $smarty->loadPlugin('smarty_compiler_switch'); Version 3.2: Fixed a bug when chaining multiple {case} statements without a {break}. Version 3.5: Updated to work with Smarty 3.0 release. (Tested and working with 3.0.5, no longer compatible with 3.0rcx releases.) Version 3.6: Updated to work with Smarty 3.1 release. (Tested and working on 3.1.3, No longer compatible with 3.0 releases.) Version 3.7: Updated to work with Smarty 3.1.28 release. (Tested and working on 3.1.29,)
Bugs/Notes:
Located at tpl/smarty/plugins/compiler.switch.php
Methods summary
public
string
|
#
compile( string $args, Smarty_Compiler $compiler )
Start a new switch statement. A variable must be passed to switch on. Also, the switch can only directly contain {case} and {default} tags. |
Methods inherited from Smarty_Internal_CompileBase
Properties summary
public
array
|
$required_attributes
Array of names of required attribute required by tag |
#
array('var')
|
public
array
|
$optional_attributes
Array of names of optional attribute required by tag use array('_any') if there is no restriction of attributes names |
#
array()
|
public
array
|
$shorttag_order
Shorttag attribute order defined by its names |
#
array('var')
|