protected function generate_op_if($details, &$body) { if (self::$if_empty && $this->is_var_filter($details['expr']) && count($details['expr']['var_filter']) == 1) { /* if we are doing if <Variable> it should check if it exists without throw any warning */ $expr = $details['expr']; $expr['var_filter'][] = 'empty'; $variable = $this->get_filtered_var($expr['var_filter'], $var); $details['expr'] = hexpr($variable, '===', FALSE)->getArray(); } $this->check_expr($details['expr']); $expr = Haanga_AST::fromArrayGetAST($details['expr']); $body->do_if($expr); $this->generate_op_code($details['body'], $body); if (isset($details['else'])) { $body->do_else(); $this->generate_op_code($details['else'], $body); } $body->do_endif(); }
/** * Generate code to print a variable with its filters, if there is any. * * All variable (except those flagged as |safe) are automatically * escaped if autoescape is "on". * */ protected function generate_op_print_var($details, &$body) { $details = $this->get_filtered_var($details['variable'], $variable, TRUE); if (!Haanga_AST::is_var($details) && !Haanga_AST::is_exec($details)) { /* generate_variable_name didn't replied a variable, weird case currently just used for {{block.super}}. */ $this->do_print($body, $details); return; } if (!$this->is_safe($details) && self::$autoescape) { $args = array($details); $details = $this->do_filtering('escape', $args); } if (is_array($details)) { $details = Haanga_AST::fromArrayGetAST($details); } $this->do_print($body, $details); }