-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Using the new template naming in the documentation #3849
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
👍 |
@javiereguiluz Could you please link to the pull request where this feature has been implemented? |
I'm -1, but could be persuaded :). The problem isn't changing the docs, it's now that the internet will be showing 2 very different ways to render templates, and that will cause confusion. The official docs will now show a different rendering mechanism than years of blog posts on the web. So even if the new syntax is a little bit more clear, the end result imo is much cloudier and confusing as people google for answers. |
I tend to go in the same direction as @weaverryan. People are now used to the current syntax. We can introduce the new syntax, because it's slighty better, but then we have to explain the old syntax too. It's better to stick to one syntax for the docs and keep using that, except for cases where the old way is deprecated. But then, we have to add lots of versionadded directives. We already have docs about this new way in http://symfony.com/doc/current/cookbook/templating/namespaced_paths.html. We may want to put that a little bit closer to the spotlight, by adding some references to it in templating related docs. |
@weaverryan @wouterj I completely agree with your concerns! However, as you say that you could be persuaded, let's talk about some similar changes that we made in the past:
Lastly, although breaking community resources such as tutorials, blog posts, screencasts and books is definitely something to consider, please think that the new template naming is better, easier to explain and even faster to execute! |
I will admit that beginners have a hard time understanding the What about the overriding templates using this? I thought I remembered hearing that a downside to the namespaces were that if 3rd party bundles used them, you couldn't override their templates in the traditional way. Or is that not an issue anymore? I realize we're teaching people how to develop their bundles (not 3rd party bundles), but I'd also like to stay consistent with how 3rd party bundles work. If this isn't an issue anymore and 3rd party bundles are moving towards this syntax, that would be a big plus. I'm being persuaded... but not totally sure yet. |
To be honest, I don't see why the You listed, except from the If we are going to update all docs to the The same goes for controllers as services. We haven't updated the docs to that. Also, the
Wait I'm confused already too. In configuration files you will use But as always, I just tell my opinion. If more people agree with your proposal, just do it :) |
@wouterj I prefer |
@lyrixx you are confused too. Your path doesn't work, it should be On top of this, we loose the unified template name. Afaics, the |
@wouterj saying that the meaning of this notation changes in controllers / config files / templates is a bit cheating ... because in the old syntax it also changes. Let me explain the big difference of the new notation using a real example. I've started to work as a Symfony trainer and one of the workshops is for the absolute beginners. Take a look at the differences between explaining the old and the new syntax. Old syntax
New syntax
Maybe I've exaggerated the last example ;) but hopefully I made my point. |
This is wrong. |
Which obviously makes things worse because there is not an standard template naming. The problem with the old syntax is that the controller part can be:
With the new syntax there are no problems because there is no controller and no template ... just a template file path. |
I don't like the With the new syntax: (slightly favoured in my opinion, just like you did 😉)
|
@wouterj again .... the differences with the Regarding the PHP templates differences, to be honest I don't mind. There are millions of differences between PHP and Twig templates. And it's not crazy to think that Symfony 3.0 could remove the PHP templates altogether in favor of Twig. |
@javiereguiluz The old syntax is less confusing when I read it as
Solution is simple: don't talk about PHP templates. See symfony/symfony#9193 (comment) if you need an argument |
@stof "unfortunately", people read the official Symfony documentation. For instance, in this page you can read the following:
As you can see, no mention of |
@javiereguiluz The naming in the doc can also be changed. Isn't this discussion precisely about changing the way it is documented ? |
Let's recap the pros and cons expressed so far: Cons
Pros
|
Another pro: it works when using Twig outside Symfony as well (in Silex for instance, which is exactly why the webProfilerBundle switched to it) For the override of template, it works to overwrite templates in |
The second format is more aligned with the syntax used in all Symfony code. This is important because provides integrity in the definition of a project and helps train new users of the tool. But, Is true that changing something like that means maintaining of both formats along the time at least until the end of the oldest version support. Also change all documentation (which is no small). This kind of decisions are like... "whatever you do, you'll be right".
... so taking into account the cost of change, I do not think that's a good idea |
I would like to mention that the new format is inconsistent with the existing resource syntax, as has been discussed before (can't find the discussion at the moment). I.e.
I personally find this subtle difference very prone to mistakes and thus prefer the colon syntax for templates. |
@webmozart the inconsistencies of the old syntax mean that there is more than one way to name a template in this case:
With the new syntax, you always get the same value: Symfony project usually tries to remove inconsistencies and ambiguities like this one. Another inconsistency of the old syntax: according to the official documentation, the middle part of the template naming is the controller part. The problem is that sometimes is a controller, sometimes is just a directory and sometimes is a directory inside a controller. |
Again, this is not an inconsistency of the syntax, but an issue with the docs. Fix the docs to replace "Controller" with "Directory" and add a little sentence saying that by convention, the directory usually has the same name as the controller. |
... and we'll have again the first inconsistency: |
And in all cases, it still refers to the directory :) Sometimes, there is no directory (so directory = empty), something there is a directory (so directory = directory) and sometimes, it's a subdirectory (so directory = subdirectory). You can find inconsistencies in all things this way. Let's agree that we disagree and will never agree on this topic and let other people decide. So we keep to the raw facts, without a bit "Javier" or "Wouter" flavour: Cons
Pros
|
This does not need to stay unconfirmed. I gave the answer in #3849 (comment) |
thanks @stof, fixed it |
Gosh, this is a hot debate. Now I'm leaning slightly towards the new syntax 😇 @webmozart Brought up the point about it being inconsistent with the resource importing (e.g. |
I must say that I don't use the new namespaced syntax mostly because I don't see it used, and referenced to, in the documentation, and it's a shame because I find it more elegant and less error prone. All this So let's not get stuck in the past and let's move forward. 👍 |
@iamdto I agree with your comment, except for the last quote. Apparently, Facebook has realized that breaking things is not a good idea after all. At the most recent F8 conference: Facebook's era of breaking things is over Here it is their new motto: "fast ... but stable" |
You're right :) |
Yea again, I'm actually +1 for this now - I think we need to be more aggressive with usability things. I would love to know if Fabien feels strongly one way or another - Javier have you chatted with him? |
@weaverryan I haven't talked to him yet ... but let's ping him (@fabpot) to know his opinion about this discussion. |
@weaverryan It's not just whether |
@weaverryan @webmozart I agree with Bernhard: we're trying to fix some inconsistencies by introducing a new one: In configuration files: The inconsistency is introduced in this line of the TwigBundle. Maybe we could deprecate this behaviour and start registering namespaces with the |
Oh wow, I didn't even notice the missing I agree with @javiereguiluz - I would like to deprecate (if possible) the current behavior and require the Thanks - great conversation! |
In general i'm 👍 in using the new syntax.
What does this actually mean? I guess it's about symfony/symfony#9085
Why not go the other way round and also allow resources to be specified without suffix The "Bundle" suffix was probably left out to be as short as possible. We could do the same for resources. The question is when somebody uses a Bundle without the |
@javiereguiluz now we have the best practices, do you still think this issue is relevant? (especially since we updated the Templating book chapter to make things as clear as possible?) |
In my opinion we should always use the best-practice notation ( |
@javiereguiluz I know this issue and (symfony/symfony#11051) got a little crazy, but I think we're close now - and I agree with what you said above. But, the core code is still stripping off the A) Deprecate the Also - I want to keep things focused - but this plan could possibly be changed if we imagine using puli in Symfony 3.0. In that case, we'd need to brain-storm how that would look and move in that direction instead of moving towards (B) and (C) above (cc @webmozart). Make sense? |
@weaverryan I would like to work on Puli integration directly into Symfony once 2.7 is released, as the feature freeze is too soon now. Also this means that a stable version of Puli will be available. For reference, with Puli the paths will be normalized to:
If a resource is loaded through Puli (e.g. a Twig template or a config file), references to other resources can use relative paths:
|
@webmozart what would be the Puli path for a template stored in the global And I have another question: since you already have tested some proof-of-concept integrations of Puli + Symfony: what's the impact of Puli on performance? (I'm not implying that Puli degrades performance ... I'm just curious to know if Puli improves or degrades or maintains Symfony performance). Thanks. |
@javiereguiluz The application path for your example would be:
For DX reasons, I even think we should get rid of the At the moment, Puli degrades performance directly after clearing the cache. This needs to be optimized. Once the cache is loaded, performance is the same as now, since Puli is not accessed anymore then. |
Closing this issue because there is no consensus to make this change. In any case, docs already use the syntax recommended by the Symfony Best Practices for global templates and the traditional syntax ( |
The other day, @lyrixx and I were talking about Twig template naming and locations and he asked if we could update the official Symfony documentation to use the new template syntax.
Imagine that your project has the following four templates:
Using the traditional syntax, you have four different formats to explain:
Using the new namespaced syntax everything is straightforward:
With the new syntax you only have to write the path from
Resources/views/
, without thinking if the template is associated with a controller or if it's stored in a subdirectory. Everything is much easier to explain, specially for Symfony newcomers.Forgetting for a moment about the colossal effort that would be needed to update all the documentation, what do you think about this proposal?
The text was updated successfully, but these errors were encountered: