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

Add Best Practice guideline for partials/include#8608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@timonf
Copy link
Contributor

@timonftimonf commentedNov 9, 2017
edited
Loading

Hi 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/blog

I 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,
Timon

@wouterjwouterj added this to the2.7 milestoneNov 12, 2017
@wouterj
Copy link
Member

👍 I like it.

/cc@javiereguiluz please share your thoughts on this as you're the best practices master :)

Copy link
Member

@javiereguiluzjaviereguiluz left a comment

Choose a reason for hiding this comment

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

I agree with this proposal! the leading underscore has been an unofficial best practice for more than 12 years (since symfony 1) so it's time to make it official!

If I may, I'd like to propose some minor rewordings to this proposal:

..best-practice::    Prefix the file name of partial templates with an underscore.You often want to reuse template code using the ``include()`` function to avoidredundant code. To better differentiate those partials in the filesystem, youshould prefix their file names with a single underscore (e.g. ``_footer.html.twig``).

Thanks!

@weaverryan
Copy link
Member

I like it! Thank you Timon!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@javiereguiluzjaviereguiluzjaviereguiluz approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

5 participants

@timonf@wouterj@weaverryan@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp