private function addVariable ($var, $value) {
// Add it to the stack
$this->varStack->append(array(
- 'name' => $var,
- 'value' => $value
+ 'name' => trim($var),
+ 'value' => trim($value)
));
}
if ((substr($varMatches[2][$key], 0, 1) == "\"") && (substr($varMatches[2][$key], -1, 1) == "\"")) {
// Free string detected! Which we can assign directly
$this->assignVariable($var, $varMatches[3][$key]);
- } else {
+ } elseif (!empty($varMatches[2][$key])) {
// Non-string found so we need some deeper analysis...
// @TODO Unfinished work or don't die here.
die("Deeper analysis not yet implemented!");
} // END - if (count($this->loadedRawData) ...
}
+ /**
+ * Inserts all raw templates into their respective variables
+ *
+ * @return void
+ */
+ private function insertRawTemplates () {
+ // Load all templates
+ foreach ($this->rawTemplates as $template=>$content) {
+ // Set the template as a variable with the content
+ $this->assignVariable($template, $content);
+ }
+ }
+
/**
* Getter for raw template data
*
throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->readConfig("code_template_type")), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED);
}
- // Get the raw data. Thanks to Flobee(R) for given me a hint using the
- // modifier "m" in regular expressions. I had implemented a regex here
- // like this: (\n|\r)
+ // Get the raw data.
$rawData = $this->getRawTemplateData();
// Remove double spaces and trim leading/trailing spaces
//
// The main analysis
$this->analyzeTemplate($templateMatches);
+ $this->debugInstance();
// Compile raw template data
$this->compileRawTemplateData($templateMatches);
// Are some raw templates found and loaded?
if (count($this->rawTemplates) > 0) {
- die("NOT YET IMPLEMENTED");
+ // Insert all raw templates
+ $this->insertRawTemplates();
}
+
} // END - if($templateMatches ...
}
break;
default: // Unknown type found
+ // Construct message
+ $msg = sprintf("[%s:] Unknown/unsupported template type <strong>%s</strong> detected.",
+ $this->__toString(),
+ $this->getTemplateType()
+ );
+
if ((is_object($this->getDebugInstance())) && (method_exists($this->getDebugInstance(), 'output'))) {
// Use debug output handler
- $this->getDebugInstance()->output(sprintf("[%s:] Unbekannter Template-Typ <strong>%s</strong> erkannt.",
- $this->__toString(),
- $this->getTemplateType()
- ));
+ $this->getDebugInstance()->output($msg);
die();
} else {
// Put directly out
// DO NOT REWRITE THIS TO app_die() !!!
- die(sprintf("[%s:] Unbekannter Template-Typ <strong>%s</strong> erkannt.",
- $this->__toString(),
- $this->getTemplateType()
- ));
+ die($msg);
}
break;
}
);
// Run the code
- @eval($eval);
+ eval($eval);
}
// Return the requested instance