|
@@ -10,6 +10,25 @@
|
|
|
private static $templates = [];
|
|
|
public static $cachedir;
|
|
|
public static $basedir = __DIR__;
|
|
|
+ private static $tidy;
|
|
|
+ private static $tidyConfig = [
|
|
|
+ 'indent'=>true,
|
|
|
+ 'tab-size'=>4,
|
|
|
+ 'wrap'=>0,
|
|
|
+ 'wrap-asp'=>false,
|
|
|
+ 'wrap-attributes'=>false,
|
|
|
+ 'wrap-jste'=>false,
|
|
|
+ 'wrap-php'=>false,
|
|
|
+ 'wrap-script-literals'=>false,
|
|
|
+ 'wrap-sections'=>false,
|
|
|
+ 'char-encoding'=>'utf8',
|
|
|
+ 'newline'=>'LF',
|
|
|
+ 'tidy-mark'=>true,
|
|
|
+ 'merge-divs'=>false,
|
|
|
+ 'merge-spans'=>false,
|
|
|
+ 'logical-emphasis'=>false,
|
|
|
+ 'literal-attributes'=>true
|
|
|
+ ];
|
|
|
private static $regex = [
|
|
|
'match'=>'/\{([^#\/?_][^}\n]*?)\}/i',
|
|
|
'parentmatch'=>'/\{\.\.\/([^#\/?_][^}\n]*?)\}/i',
|
|
@@ -233,6 +252,17 @@
|
|
|
file_put_contents($this->path, static::compile($this->template));
|
|
|
$output = static::execute($this->path, $data);
|
|
|
}
|
|
|
+ if(class_exists('tidy')){
|
|
|
+ if(is_null(static::$tidy)){
|
|
|
+ static::$tidy = new \tidy();
|
|
|
+ }
|
|
|
+ $tidy = static::$tidy;
|
|
|
+ $tidy->parseString($output, static::$tidyConfig);
|
|
|
+ if(!$tidy->cleanRepair()){
|
|
|
+ throw new \Exception($tidy->errorBuffer);
|
|
|
+ }
|
|
|
+ $output = "{$tidy}";
|
|
|
+ }
|
|
|
if($this->fire('after', $output) === false){
|
|
|
throw new Exception("Render on template {$this->name} cancelled. After");
|
|
|
}
|