47 lines
855 B
PHP
Executable File
47 lines
855 B
PHP
Executable File
<?php
|
|
|
|
class Template extends Engine {
|
|
|
|
public static function fromString ( $string, $dir = '', $root = '', $cache = '', $basename = '' ) {
|
|
|
|
$instance = new static($dir, $root, $cache, $basename);
|
|
|
|
$instance->code = SeTMLInterface::compileString($string);
|
|
$instance->source = $string;
|
|
|
|
return $instance;
|
|
|
|
}
|
|
|
|
/**
|
|
* Rendering
|
|
*/
|
|
|
|
public function run ( $data = array() ) {
|
|
|
|
if ( !( $data instanceOf SeTMLRuntime ) )
|
|
$data = new SeTMLRuntime($data);
|
|
|
|
try {
|
|
|
|
return $data->run(
|
|
$this->include ?
|
|
$this->include :
|
|
$this->code,
|
|
$this,
|
|
$this->include ? 1 : 0
|
|
);
|
|
|
|
} catch ( Exception $e ) {
|
|
|
|
throw new Exception('Error during program execution !', 0, $e);
|
|
|
|
}
|
|
|
|
throw new Exception('File has not been compiled ! Moreover, it should not be possible to be here !');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|