4 * Smarty Internal Plugin Compile Continue
6 * Compiles the {continue} tag
13 * Smarty Internal Plugin Compile Continue Class
15 class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase {
16 // attribute definitions
17 public $optional_attributes = array('levels');
18 public $shorttag_order = array('levels');
21 * Compiles code for the {continue} tag
23 * @param array $args array with attributes from parser
24 * @param object $compiler compiler object
25 * @param array $parameter array with compilation parameter
26 * @return string compiled code
28 public function compile($args, $compiler, $parameter)
30 $this->compiler = $compiler;
31 $this->smarty = $compiler->smarty;
32 // check and get attributes
33 $_attr = $this->_get_attributes($args);
35 if ($_attr['nocache'] === true) {
36 $this->compiler->trigger_template_error('nocache option not allowed', $this->compiler->lex->taglineno);
39 if (isset($_attr['levels'])) {
40 if (!is_numeric($_attr['levels'])) {
41 $this->compiler->trigger_template_error('level attribute must be a numeric constant', $this->compiler->lex->taglineno);
43 $_levels = $_attr['levels'];
47 $level_count = $_levels;
48 $stack_count = count($compiler->_tag_stack) - 1;
49 while ($level_count > 0 && $stack_count >= 0) {
50 if (in_array($compiler->_tag_stack[$stack_count][0], array('for', 'foreach', 'while', 'section'))) {
55 if ($level_count != 0) {
56 $this->compiler->trigger_template_error("cannot continue {$_levels} level(s)", $this->compiler->lex->taglineno);
58 // this tag does not return compiled code
59 $this->compiler->has_code = true;
60 return "<?php continue {$_levels}?>";