Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite00a3a2

Browse files
committed
feature#8608 Add Best Practice guideline for partials/include (timonf, weaverryan)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes#8608).Discussion----------Add Best Practice guideline for partials/includeHi there,I was wondering if there is no Best Practice guide for partials/includes. So I would recommend to use a single prefixed underscore to determine such partials easily like in the Symfony demo application:https://github.com/symfony/demo/tree/master/templates/blogI saw often other solutions like `@SomeBundle:Partials/post_form.html.twig`. But I like the approach from the Symfony demo application, so it should be a Best Practice guideline :)Regards,TimonCommits-------bbd705d Added Best Practice guideline for partials/include
2 parentsa364651 +bbd705d commite00a3a2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎best_practices/templates.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ scattered through lots of bundles.
5353

5454
Use lowercased snake_case for directory and template names.
5555

56+
..best-practice::
57+
58+
Use a prefixed underscore for partial templates in template names.
59+
60+
You often want to reuse template code using the ``include`` function to avoid
61+
redundant code. To determine those partials easily in the filesystem you should
62+
prefix partials and any other template without HTML body or ``extends`` tag
63+
with a single underscore.
64+
5665
Twig Extensions
5766
---------------
5867

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp