Skip to content

Commit

Permalink
Support underscored partials in a partials directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmcdade committed May 26, 2021
1 parent e8d977a commit f0df43e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Tags/Partial.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ protected function viewName($partial)
return $subdirectoried;
}

if (view()->exists($underscored_subdirectoried = 'partials.'.$this->underscoredViewName($partial))) {
return $underscored_subdirectoried;
}

return $partial;
}

Expand Down

3 comments on commit f0df43e

@jasonvarga
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackmcdade can you add a test?

/** @test */
public function gets_partials_from_partials_directory()
{
$this->viewShouldReturnRaw('partials.sub.mypartial', 'the partial content');
$this->assertEquals('the partial content', $this->partialTag('sub.mypartial'));
}
/** @test */
public function gets_partials_with_underscore_prefix()
{
$this->viewShouldReturnRaw('sub._mypartial', 'the partial content');
$this->assertEquals('the partial content', $this->partialTag('sub.mypartial'));
}

@jackmcdade
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonvarga Nuts, too late. Sorry dude!

@jasonvarga
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, I added them 🤘

Please sign in to comment.