https://discord.umbraco.com logo
Wondering if theres any RCL gurus that
# package-development
t
Wondering if theres any RCL gurus that have worked with shipping partial views in their RCL? Could do with a little guidance 😅 Working on a table package which we want to ship a bit of a theme renderer similar to how Umbraco Forms does it, In the package, ive got a default view under /Views/Partials/Tables/default.cshtml I can pack that and render it in the target site no issues! However, I was under the interpretation that if you supply a file mimicking the path and name in the same location in the Site project, it would use that over the RCL version, in my case, it seems hard stuck on wanting to use the RCL view instead of the physical file. Have I forgot a bit of a crucial step to making overridable views in an RCL?
l
No it should be the correct behaviour that you can override the view. Are you sure you are using the correct path?
t
Was under the impression I was! Package projects path is /Views/Partials/Tables/default.cshtml Then in my dev site, have done exactly the same In this case, the default.cshtml in the Siteproject just has a P tag in it for me to try and get it working, however if I call say: @Html.PartialAsync("Tables/default") It ends up rendering the RCL view. Wondering if I've mucked something up in Extension to render the table https://cdn.discordapp.com/attachments/1457713293493014743/1457714687906021522/image.png?ex=695d0218&is=695bb098&hm=1d7c0911f16995a5c3ea088ac859f1bd211c1d397b6590b7ad6759bc63516da1& https://cdn.discordapp.com/attachments/1457713293493014743/1457714688216273111/image.png?ex=695d0218&is=695bb098&hm=93532c20a0c10a6f5fb80f9a53037fe56beb5a87b4cf187e3009df4aa9871a74& https://cdn.discordapp.com/attachments/1457713293493014743/1457714688727973952/image.png?ex=695d0218&is=695bb098&hm=b7a86e4da12c0d94a47e979fd9d5109a38c40d32d30151ecaa55dfab0d3d6d04&
p
What you could try is publish your site to an empty folder. There you can also see where the files are ending up in. Perhaps they are not in the places you expect them in
m
check you have and then when you've built/packed if you check the dll in your favourite decompiler.. you should see some
AspNetCoreGeneratedDocuments
here in dotnetpeek... for a simple single view... https://cdn.discordapp.com/attachments/1457713293493014743/1457719661364904019/image.png?ex=695d06ba&is=695bb53a&hm=afe66867df6dd2624106152443629ac93b244e96c6a73aa3a019cdbf1101fe9c&
t
Yeah looks like im seeing some funkiness in actually whats building here! Thanks for the pointers. It looks like it must be serving them from some cache location, as the built DLL actually doesnt contain the GeneratedDocuments, so im chasing a white rabbit that didnt exist! https://cdn.discordapp.com/attachments/1457713293493014743/1457720394860597299/image.png?ex=695d0769&is=695bb5e9&hm=ad2e0ba675012b661cbf53c555a12ba30ee9ca643ba14efce3cfe36c52bc3a08&
p
How is your .csproj looking of the project where you want to include the razor files?
t
Ever had that feeling where you want to just put your head in the sand like an ostrich?
p
Well, lessons learned 😉 Now you know what to check for next time
t
Much appreciated First time packaging up actual Views with a package so theres certainly been a lot of teething pain
p
Yeah, they can be a big pain. It's better nowadays than before but it sucks that you aren't able to see the files in your explorer
t
Yeah - the next hardest bit im fighting with now is getting it to override during runtime without the need of Rebuilding similar to when you include a Forms theme with the same name. Got a little method of: @await Html.RenderTableAsync(model, propertyAlias, theme) In which using the _viewEngine.GetView() method seems to always prefer grabbing the RCL view. The GetView can find the Physical template, but always ends up resolving to RCL first then, Im guessing I'd have to override the GetView logic to tell it to prefer physical over generated for the purposes of this extension method
p
But if it is an extension on the HtmlHelper, can't you return html.RenderPartialAsync?
t
Just gave it a try and seen that it resolves to the RCL first as well. Im now back to the drawing board of how this ViewFinding works https://cdn.discordapp.com/attachments/1457713293493014743/1457743766503821449/image.png?ex=695d1d2d&is=695bcbad&hm=39fabc22a4e18a0c43ec87ad667f5d251191452820bc964edb2678b4a7d3285f&
h
I've had this issue and it was caused by my website project file having the view added to it, so had to remove all references to it then it worked ok.
t
So went checking around and can confirm there arent any references to it. Span up a fresh "bare bones as you can get" local instance of Umbraco, installed my nupkg and loaded up a template trying to output the "Override" view. It still loads the RCL /Views/Partials/Tables/default.cshtml instead. If I swap the project to RazorCompileOnBuild = true. Then it picks up the physical override correctly, which makes me start to think is that after the v17 change of the RazorRuntime being moved into its own package, Does that result in Compiled Views taking precedence over physical views because the compiled view is "ready to go" per say? Granted, my knowledge of rendering engines is next to nil so I could be barking up the wrong tree https://cdn.discordapp.com/attachments/1457713293493014743/1457765848440901783/image.png?ex=695d31be&is=695be03e&hm=ef25c4f8ff5eb28248cbed2e1409208c3e682d9b2184d19aaf431d2831512a74&
p
t
It is indeed!
Still a lot of improvements to make, but happy to have finally put something out there for people to try. After working on Umbraco for the best part of 12/13 years it was about time I atleast contributed something back 😅
p
I think the Github link is either broken or the repository is still private. I get a 404 when I go to it
t
Ah yes, the one down the bottom near the issues & contributions section? Spotted and pushed an updated link to that not too long ago. Just gotta wait for the marketplace to reindex it. https://github.com/WebwondersNL/Webwonders.Umbraco.TableEditor https://cdn.discordapp.com/attachments/1457713293493014743/1458028243398561948/image.png?ex=697c789e&is=697b271e&hm=946ed9b42293747743ff8da001c8243153149354741856b9ffb161aeab264b93&
p
Ah, that makes sense
10 Views