function publish($filePage, $data = []) { $hermeticRender = function ($____f, $____d) { extract($____d); unset($____d); ob_start(); include $____f; return ob_get_clean(); }; $filePage = concatPath('./page/', $filePage); Vue::setContent($hermeticRender($filePage, $data)); ob_start(); include 'template.php'; $body = ob_get_contents(); ob_end_clean(); //remove redundant (white-space) characters $replace = array('/\\>[^\\S ]+/s' => '>', '/[^\\S ]+\\</s' => '<', '/([\\t ])+/s' => ' ', '/^([\\t ])+/m' => '', '/([\\t ])+$/m' => '', '~//[a-zA-Z0-9 ]+$~m' => '', '/[\\r\\n]+([\\t ]?[\\r\\n]+)+/s' => "\n", '/\\>[\\r\\n\\t ]+\\</s' => ">\n<", '/}[\\r\\n\\t ]+/s' => '}', '/}[\\r\\n\\t ]+,[\\r\\n\\t ]+/s' => '},', '/\\)[\\r\\n\\t ]?{[\\r\\n\\t ]+/s' => '){', '/,[\\r\\n\\t ]?{[\\r\\n\\t ]+/s' => ',{', '/\\),[\\r\\n\\t ]+/s' => '),', '~([\\r\\n\\t ])?([a-zA-Z0-9]+)="([a-zA-Z0-9_/\\-]+)"([\\r\\n\\t ])?~s' => '$1$2=$3$4'); //$body = preg_replace(array_keys($replace), array_values($replace), $body); echo $body; }