Skip to content

Commit

Permalink
* 支持多级视图目录
Browse files Browse the repository at this point in the history
  • Loading branch information
pinguo-xudianyang committed Jun 15, 2017
1 parent b1684b6 commit 4a13884
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/Template/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,19 @@ public function setName($name)
{
$this->name = $name;

$parts = explode('::', $this->name);
$parts = explode('/', $this->name);
$file = array_pop($parts);
$folder = implode('/', $parts);

if (count($parts) === 1) {
$this->setFile($parts[0]);
} elseif (count($parts) === 2) {
$this->setFolder($parts[0]);
$this->setFile($parts[1]);
if (!empty($folder) && !$this->engine->getFolders()->exists($folder)) {
$this->engine->addFolder($folder, $folder);
}

if (empty($folder)) {
$this->setFile($file);
} else {
throw new LogicException(
'The template name "' . $this->name . '" is not valid. ' .
'Do not use the folder namespace separator "::" more than once.'
);
$this->setFile($file);
$this->setFolder($folder);
}

return $this;
Expand Down

0 comments on commit 4a13884

Please sign in to comment.