<?php
 class vB_Utility_Template_ParserNode_Tag_Every extends vB_Utility_Template_ParserNode_Tag { public function validate() : array { $varname = $this->main_node->attributes['index'] ?? null; $count = $this->main_node->attributes['count'] ?? null; $start = $this->main_node->attributes['start'] ?? 0; $errors = []; if (!$varname) { $errors[] = 'no_variable_specified'; } else { if (!$this->validateVarStrict($varname)) { throw new vB_Utility_Template_Parser_FatalError(['template_parser_invalid_varname', $this->nodename()]); } } if (!$count) { $errors[] = ['template_parser_count_required', $this->nodename()]; } else { if ($start >= $count) { $errors[] = ['template_parser_start_greater_than_count', $this->nodename()]; } } return $errors; } public function compile() : string { $varname = $this->main_node->attributes['index'] ?? null; $count = intval($this->main_node->attributes['count'] ?? 1); $start = intval($this->main_node->attributes['start'] ?? 0); $varnameText = $this->compileVarStrict($varname); $condition = "isset($varnameText) AND (($varnameText % $count) == $start)"; $children = $this->parser->_parse_nodes($this->main_node->childNodes()); $output = "''; if (" . $condition . ') {
			' . $this->parser->outputVar . " .= " . $children . ";" . '
		} ' . $this->parser->outputVar . " .= ''"; return $output; } } 