Skip to content

Commit

Permalink
Merge pull request #397 from CPS-IT/fix/target-template-suffix
Browse files Browse the repository at this point in the history
[BUGFIX] Correctly remove twig file extension with target file given
  • Loading branch information
eliashaeussler authored Nov 29, 2023
2 parents 8ec1064 + 7a513b3 commit 785bef3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Builder/Writer/TemplateWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function write(
$renderResult = $renderer->render($instructions, $file->getFilename(), $variables);
$targetFile = Helper\FilesystemHelper::createFileObject(
$instructions->getTemporaryDirectory(),
$targetFile ?? (string) preg_replace('/\.twig$/', '', $file->getRelativePathname()),
(string) preg_replace('/\.twig$/', '', $targetFile ?? $file->getRelativePathname()),
);

$this->filesystem->dumpFile($targetFile->getPathname(), $renderResult);
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Builder/Writer/TemplateWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function writeWritesRenderedTemplateFileToGivenTargetFile(): void
$file = new Finder\SplFileInfo($templateFile, dirname($templateFile), basename($templateFile));

$expected = $instructions->getTemporaryDirectory().'/overrides/dump.json';
$actual = $this->subject->write($instructions, $file, 'overrides/dump.json', ['bar' => 'bar']);
$actual = $this->subject->write($instructions, $file, 'overrides/dump.json.twig', ['bar' => 'bar']);

self::assertSame($expected, $actual->getPathname());
self::assertFileExists($expected);
Expand Down

0 comments on commit 785bef3

Please sign in to comment.