Skip to content

Commit f163b5a

Browse files
committed
fix(Parser): rendu de vue de fichier non-php
1 parent 647663e commit f163b5a

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/View/Parser.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
8282
$saveData = $this->saveData;
8383
}
8484

85-
$fileExt = pathinfo($view, PATHINFO_EXTENSION);
86-
$view = empty($fileExt) ? $view . '.php' : $view; // allow Views as .html, .tpl, etc (from CI3)
85+
if ('' === $ext = pathinfo($view, PATHINFO_EXTENSION)) {
86+
$view .= '.php';
87+
$ext = 'php';
88+
}
8789

88-
$cacheName = $options['cache_name'] ?? str_replace('.php', '', $view);
90+
$cacheName = $options['cache_name'] ?? str_replace('.' . $ext, '', $view);
8991

9092
// Was it cached?
9193
if (isset($options['cache']) && ($output = cache($cacheName))) {
@@ -98,7 +100,7 @@ public function render(string $view, ?array $options = null, ?bool $saveData = n
98100

99101
if (! is_file($file)) {
100102
$fileOrig = $file;
101-
$file = $this->locator->locateFile($view, 'Views');
103+
$file = $this->locator->locateFile($view, 'Views', $ext);
102104

103105
// locateFile will return an empty string if the file cannot be found.
104106
if (empty($file)) {

0 commit comments

Comments
 (0)