[--write]\n\n";
print "Validates a template against the DOM model. Use --write with caution!\n";
exit;
} elseif (strpos($_SERVER['argv'][1], '/js/') > 0) {
// Not parsing JavaScript templates!
print "Warning: Not parsing JavaScript ".$_SERVER['argv'][1].".\n";
exit;
}
print "Validating template ".$_SERVER['argv'][1]."...\n";
$doc = new DOMDocument();
$doc->formatOutput = TRUE;
$doc->preserveWhiteSpace = FALSE;
$doc->encoding = 'UTF-8';
$doc->xmlVersion = '1.1';
$doc->loadHTMLFile($_SERVER['argv'][1]);
$data = $doc->saveHTML();
$newData = str_replace("
", "
\n", $data);
$newData = str_replace(PHP_EOL . PHP_EOL, PHP_EOL, $newData);
$array = explode(PHP_EOL, $newData);
array_shift($array);
array_shift($array);
unset($array[count($array) - 1]);
unset($array[count($array) - 1]);
$newData = implode(PHP_EOL, $array).PHP_EOL;
// Has a template changed?
if ($data != $newData) {
// Has changed
print "Template ".$_SERVER['argv'][1]." has maybe issues.\n";
} else {
// Has not changed
print "Template ".$_SERVER['argv'][1]." might be issue-free.\n";
}
if ((isset($_SERVER['arv'][2])) && (strtolower($_SERVER['arv'][2]) == '--write')) {
print "Writing document...\n";
file_put_contents($_SERVER['argv'][1], $data);
} // END - if
// [EOF]
?>