What is the difference between Partial and Slot in Symfony?

The two concepts of Partial and Slot seem the same to me. Both of these functions replace placeholders in the template with actual markup.

When should I use Partial and when should I use Slot ?

+3
source share
4 answers

The main difference between slots and particles is that the rendering for a given slot is inside a specific template. In contrast, a partial is simply the inclusion of a template in another template.

" , , ( , ). - , ( , ). , , , , template ( ), , ."

:

  • - , ( ), , , .
  • - , 3 "", , " -1", " -2" " -3". , ( ), .

, .

+4

:

include_partial('thing', $params) _thing.php $ .

, - /:

slot('title', 'Home Page');
echo '<title>'.slot('title').'</title>'

+3

, , - Symfony . , , (PDF, 45 ).

+2
+1

Source: https://habr.com/ru/post/1755118/


All Articles