[--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("\n\n", "\n", $newData);
$array = explode("\n", $newData);
array_shift($array);
array_shift($array);
unset($array[count($array) - 1]);
unset($array[count($array) - 1]);
$newData = implode("\n", $array)."\n";
// 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 (strtolower($_SERVER['arv'][2]) == '--write') {
print "Writing document...\n";
file_put_contents($_SERVER['argv'][1], $data);
} // END - if
// [EOF]
?>