-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Removing explicit namespaces for UmbracoViewPage in templates #11318
Conversation
Hi there @callumbwhyte, thank you for this contribution! 👍 While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
Hey @callumbwhyte |
Hi @callumbwhyte .. These namespaces are required right? The only reason they do not show up as required, is because the are also present in the So if you are just installing Umbraco into a plain empty solution these would be required? |
Hey @bergmania, Great point, I definitely hadn't considered the scenario where someone might not install with the templates... This raises some further questions for me though... Is installing without templates a supported example? I assume someone would have to manually setup their Following your same argument that these users would have to add explicit references for their models, the same goes for As my proposed change is for users of the backoffice template editor, what if we added some logic to ensure a standard Let me know what you think! |
I'm not sure if it is officially supported but it is definitely possible and I have heard of some doing it this way.
I totally agree, that's why we ship the templates :)
That could be an option, but also a bit magically that the Alternatively - which is a bit complicated due to To make this in a good way, we need to move |
As mentioned, PR #11317 does exactly that. |
Cool.. Sounds good, then I think that PR can be updated to the suggestion from this PR, and all is happy :) |
I'm not sure it's really needed. Shipping with two view content providers, one for if the template is used, and one for if it isn't, or adding more template configuration options seems like adding bloat and more to code maintain for no real benefit. My PR already allows a user to override the default view content should they wish, and the current default works for both templated solutions, and direct installs. Happy to reconsider if it's something that you think will be useful though. |
@matthewcare, my idea was to just ship with one. And that single one could be optimal for when using the template. But now with this PR, it is possible to override, so I think that is okay for the few that do not use the template. So my suggestion was simply just to do this in your PR: + content.AppendLine("@using Umbraco.Cms.Web.Common.PublishedModels;");
+ content.Append("@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage");
- content.Append("@inherits UmbracoViewPage"); |
I think I'll leave @callumbwhyte to update this PR to avoid expanding the scope of mine. With the further dicussions here, you'd realisitcally be looking at a view template which generates the following
As If we're removing namespaces, then we should also be looking at partial view / macro generation. |
Hey @callumbwhyte where's this one at? #11317 was merged a while back, does that impact on your changes here? |
Hi @callumbwhyte! Just going through some of the longer running PRs, and noticed this one (it's been a while, so there are now some conflicts sorry!) Did #11317 affect this PR, or did you need anything else to progress this one? Thanks, Emma 🙂 |
I'll close this one for now with the conclusion that #11317 does the trick for now. I feel like we need a bit more of a discussion first as to what needs to be generated before we look at a PR again so feel free to raise it at https://github.com/umbraco/Umbraco-CMS/discussions and then we can come to a consensus. Thanks all for being involved so far! 👍 |
When creating templates in the backoffice the editor adds a bunch of
@using
's that ultimately don't appear to be needed.This might be a legacy thing where IDE's wouldn't pick up references in the
Views/web.config
and so without those lines you'd have no intellisense.With V9 / netcore these references are included in the
_ViewStart.cshtml
, which most modern IDE's (Visual Studio, VS Code, Rider) do a good job of picking up. I see no reason why these lines should be there, and we can instead encourage devs to keep their views cleaner.This PR removes the explicit
Umbraco.Cms.Web.Common.PublishedModels
andUmbraco.Cms.Web.Common.Views
references from templates created via the CMS. The former is not needed, as there's already the@using ContentModels = ...
alias.If I've overlooked something here please do tell me!