From 9d55ea803496fb20b395a6dbd9145df338a3cf89 Mon Sep 17 00:00:00 2001 From: Dayle Rees Date: Sat, 22 Feb 2014 12:25:57 +0000 Subject: [PATCH] Updating generator for multiple files. --- build.xml | 2 ++ build/src/Raincolour/Core/Processor.php | 26 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/build.xml b/build.xml index f647e83..c60cfd8 100644 --- a/build.xml +++ b/build.xml @@ -11,6 +11,8 @@ + + diff --git a/build/src/Raincolour/Core/Processor.php b/build/src/Raincolour/Core/Processor.php index cfb9a85..6e74620 100644 --- a/build/src/Raincolour/Core/Processor.php +++ b/build/src/Raincolour/Core/Processor.php @@ -245,7 +245,8 @@ class Processor $path[] = $pattern->get('directory'); $path[] = $theme->get('theme.dir'); $path[] = $template->get('directory'); - $path[] = $theme->get('theme.slug').$template->get('extension'); + $name = $this->buildFileName($template->get('name'), $theme); + $path[] = $name.$template->get('extension'); // Concatonate paths with a slash. $path = implode('/', $path); @@ -253,4 +254,27 @@ class Processor // Trim extra slashes, just for fun. return preg_replace('/\/+/', '/', $path); } + + /** + * Replace theme name placeholders. + * + * @param string $name + * @param Raincolor\Containers\Theme $theme + * @return string + */ + protected function buildFileName($name, $theme) + { + if ($name == null) { + return $theme->get('theme.slug'); + } + preg_match('/%(.+)%/i', $name, $matches); + foreach ($matches as $match) { + if (strpos($match, '%') !== false) { + $key = trim($match, '%'); + $value = $theme->get($key); + $name = str_replace($match, $value, $name); + } + } + return $name; + } }