+ /**
+ * Assign (add) a given variable with a value
+ *
+ * @param $variableName The variable we are looking for
+ * @param $value The value we want to store in the variable
+ * @return void
+ * @throws EmptyVariableException If the variable name is left empty
+ */
+ public final function assignVariable ($variableName, $value) {
+ // Replace all dashes to underscores to match variables with configuration entries
+ $variableName = trim(self::convertDashesToUnderscores($variableName));
+
+ // Empty variable found?
+ if (empty($variableName)) {
+ // Throw an exception
+ throw new EmptyVariableException(array($this, 'variableName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } // END - if
+
+ // First search for the variable if it was already added
+ $index = $this->getVariableIndex($variableName);
+
+ // Was it found?
+ if ($index === FALSE) {
+ // Add it to the stack
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:ADD: ' . $variableName . '[' . gettype($value) . ']=' . $value);
+ $this->addVariable($variableName, $value);
+ } elseif (!empty($value)) {
+ // Modify the stack entry
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:MOD: ' . $variableName . '[' . gettype($value) . ']=' . $value);
+ $this->modifyVariable($variableName, $value);
+ }
+ }
+
+ /**
+ * Removes a given variable
+ *
+ * @param $variableName The variable we are looking for
+ * @param $variableGroup Name of variable group (default: 'general')
+ * @return void
+ */
+ public final function removeVariable ($variableName, $variableGroup = 'general') {
+ // First search for the variable if it was already added
+ $index = $this->getVariableIndex($variableName, $variableGroup);
+
+ // Was it found?
+ if ($index !== FALSE) {
+ // Remove this variable
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-TEMPLATE[' . __METHOD__ . ':' . __LINE__ . ']:UNSET: variableGroup=' . $variableGroup . ',variableName=' . $variableName . ',index=' . $index);
+ $this->unsetVariableStackOffset($index, $variableGroup);
+ } // END - if
+ }
+
+ /**
+ * Assigns the last loaded raw template content with a given variable
+ *
+ * @param $templateName Name of the template we want to assign
+ * @param $variableName Name of the variable we want to assign
+ * @return void
+ */
+ public function assignTemplateWithVariable ($templateName, $variableName) {
+ // Get the content from last loaded raw template
+ $content = $this->getRawTemplateData();
+
+ // Assign the variable
+ $this->assignVariable($variableName, $content);
+
+ // Purge raw content
+ $this->setRawTemplateData('');
+ }
+