<?php
 class vB_Utility_Template_ParserNode_Curly_Stylevar extends vB_Utility_Template_ParserNode_Curly { public function validate() : array { $errors = []; $attributecount = sizeof($this->main_node->attributes); if ($attributecount == 0) { $errors[] = 'no_variable_specified'; } if ($attributecount > 2 OR ($attributecount == 2 AND $this->main_node->attributes[1] !== 'withUnits')) { $errors[] = 'too_many_attributes'; } return $errors; } public function compile() : string { $varname = $this->attributeToString($this->main_node->attributes[0]); $secondParam = ''; if (($this->main_node->attributes[1] ?? '') === 'withUnits') { $secondParam = ', true'; } return 'vB_Template_Runtime::fetchStyleVar(' . $varname . $secondParam . ')'; } } 