Created
December 21, 2012 20:04
-
-
Save mishak87/4355394 to your computer and use it in GitHub Desktop.
Simple script for converting Nette templates file structure from <Presenter>.<action>.phtml or .latte to <Presenter>/<action>.latte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$root = ltrim(getcwd(), DIRECTORY_SEPARATOR); | |
foreach (scandir($root) as $file) { | |
if (preg_match('/^(?P<presenter>[^.]+)\.(?P<action>[^.]+)\.(latte|phtml)$/', $file, $matches)) { | |
$dir = $root . DIRECTORY_SEPARATOR . $matches['presenter']; | |
$filename = $dir . DIRECTORY_SEPARATOR . $matches['action'] . '.latte'; | |
if (!is_dir($dir)) { | |
mkdir($dir); | |
} | |
rename($root . DIRECTORY_SEPARATOR . $file, $filename); | |
// echo $root . DIRECTORY_SEPARATOR . $file, ' => ', $filename, "\n"; | |
} else { | |
echo "Skipped $file\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment