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

[TwigBundle] added support for Twig namespaced paths (Twig 1.10)#5660

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

Merged
fabpot merged 1 commit intosymfony:masterfromfabpot:twig
Oct 5, 2012

Conversation

@fabpot
Copy link
Member

In a template, you can now use native Twig template names, instead of
the Symfony ones:

Before (still works):

{% extends "AcmeDemoBundle::layout.html.twig" %}{% include "AcmeDemoBundle:Foo:bar.html.twig" %}

After:

{% extends "@AcmeDemo/layout.html.twig" %}{% include "@AcmeDemo/Foo/bar.html.twig" %}

Using native template names is also faster.

The only drawback is that the new notation looks similar to the way we
locate resources in Symfony, which would be
@AcmeDemoBundle/Resources/views/Foo/bar.html.twig. We could have used
the same notation, but it is rather verbose (and by the way, using this
notation did not work anyway in templates).

TODO: update documentation

In a template, you can now use native Twig template names, instead ofthe Symfony ones:Before (still works):    {% extends "AcmeDemoBundle::layout.html.twig" %}    {% include "AcmeDemoBundle:Foo:bar.html.twig" %}After:    {% extends "@AcmeDemo/layout.html.twig" %}    {% include "@AcmeDemo/Foo/bar.html.twig" %}Using native template names is also faster.The only drawback is that the new notation looks similar to the way welocate resources in Symfony, which would be@AcmeDemoBundle/Resources/views/Foo/bar.html.twig. We could have usedthe same notation, but it is rather verbose (and by the way, using thisnotation did not work anyway in templates).
@fabpot
Copy link
MemberAuthor

I forgot to mention why I'd like to include this change besides performance: this would allow to share templates between a project using the Symfony2 full-stack framework and any other project using Twig.

@henrikbjorn
Copy link
Contributor

👍 Will the old notation be deprecated at some point?

@stof
Copy link
Member

stof commentedOct 3, 2012

@fabpot does it still support overwriting templates ?

Copy link
Member

Choose a reason for hiding this comment

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

why removingBundle ? this is not consistent with the way the@ notation is done elsewhere

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

We are not consistent anyway as we go toResources/views/ when using the location notation. So, it was done for three main reasons: trying to be as far as possible as the current notation to avoid confusion (or not), removing something that is, by convention, always present anyway, and more importantly trying to be more agnostic for when the templates are used outside of the full-stack framework.

Now, I'm open to any suggestion and if the majority think we need/can keep the bundle suffix, that would fine for me as well.

fabpot added a commit that referenced this pull requestOct 5, 2012
This PR was merged into the master branch.Commits-------5c809d8 [TwigBundle] added support for Twig namespaced paths (Twig 1.10)Discussion----------[TwigBundle] added support for Twig namespaced paths (Twig 1.10)In a template, you can now use native Twig template names, instead ofthe Symfony ones:Before (still works):    {% extends "AcmeDemoBundle::layout.html.twig" %}    {% include "AcmeDemoBundle:Foo:bar.html.twig" %}After:    {% extends "@AcmeDemo/layout.html.twig" %}    {% include "@AcmeDemo/Foo/bar.html.twig" %}Using native template names is also faster.The only drawback is that the new notation looks similar to the way welocate resources in Symfony, which would be`@AcmeDemoBundle/Resources/views/Foo/bar.html.twig`. We could have usedthe same notation, but it is rather verbose (and by the way, using thisnotation did not work anyway in templates).TODO: update documentation---------------------------------------------------------------------------by fabpot at 2012-10-03T13:36:56ZI forgot to mention why I'd like to include this change besides performance: this would allow to share templates between a project using the Symfony2 full-stack framework and any other project using Twig.---------------------------------------------------------------------------by henrikbjorn at 2012-10-03T13:50:48Z:+1: Will the old notation be deprecated at some point?---------------------------------------------------------------------------by stof at 2012-10-03T14:29:50Z@fabpot does it still support overwriting templates ?
@fabpotfabpot merged commit5c809d8 intosymfony:masterOct 5, 2012
@webmozart
Copy link
Contributor

What's the reason for not also supporting this syntax in other parts of the framework, such as the controller?

return$this->renderView('@AcmeDemo/Foo/bar.html.twig',array(...));

@webmozart
Copy link
Contributor

ref#6919

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@fabpot@henrikbjorn@stof@webmozart

[8]ページ先頭

©2009-2025 Movatter.jp