/** * Map a modifier to a given function/method. * * @param string $name The name that you wish to use in the templates as a modifier. * @param mixed $function The function or method to map this name to. In case it's a method, provide this as an array containing class and method name. */ public function mapModifier($name, $function) { SpoonTemplateModifiers::mapModifier($name, $function); }
/** * Clears the entire modifiers list. */ public static function clearModifiers() { self::$modifiers = array(); }
/** * Parse the template. */ protected function parse() { // not yet parsed if (!$this->parsed) { // while developing, you might want to know about the undefined indexes $errorReporting = $this->debug ? 'E_ALL | E_STRICT' : 0; $displayErrors = $this->debug ? 'On' : 'Off'; // add to the list of parsed files $this->files[] = $this->getCompileName($this->template); // map modifiers $this->modifiers = SpoonTemplateModifiers::getModifiers(); // set content $this->content = SpoonFile::getContent($this->template); // strip php code $this->content = $this->stripCode($this->content); // strip comments $this->content = $this->stripComments($this->content); // prepare iterations $this->content = $this->prepareIterations($this->content); // parse iterations $this->content = $this->parseIterations($this->content); // parse variables $this->content = $this->parseVariables($this->content); // parse options $this->content = $this->parseOptions($this->content); // includes $this->content = $this->parseIncludes($this->content); // parse cache tags $this->content = $this->parseCache($this->content); // parse forms $this->content = $this->parseForms($this->content); // replace variables $this->content = $this->replaceVariables($this->content); // add error_reporting setting $this->content = '<?php error_reporting(' . $errorReporting . '); ini_set(\'display_errors\', \'' . $displayErrors . '\'); ?>' . "\n" . $this->content; // parsed $this->parsed = true; } }
public function testUppercase() { $this->assertEquals('HOORAY FOR BOOBIES!', SpoonTemplateModifiers::uppercase('hooray for boobies!')); $this->assertEquals('BLEÉÉÉÉ', SpoonTemplateModifiers::uppercase('bleéééé')); }