Static content of areas

Jul 9, 2012 at 5:48 PM

If I got it right, currently T4MVC looks for static content in root folders (e. g. Content, Scripts). Wouldn't it be reasonable to search for static content in areas folders too?

Coordinator
Jul 30, 2012 at 6:21 PM

Sorry for the late response. Yes, I think that would make sense. So it could look for the same set of folders under Areas\MyArea as it does at the root.

e.g. if you have Areas\MyArea\Content\foo.cs, it could generate a constant named Links.MyArea.Content.foo_css

Is that more or less what you had in mind?

Mar 8, 2013 at 1:11 AM
I know this was actually implemented in previous versions because one of my older projects had it working. Now that I updated T4MVC in it, it stopped working: there is no Areas under Links. Is that a bug or a breaking change?
Coordinator
Mar 8, 2013 at 1:27 AM
I don't recall this specifically changing. Can you compare the two versions you're using to see what might have change to affect this? It should be around ProcessStaticFiles.
Mar 8, 2013 at 2:16 AM
I can't compare them. It was just a dll reference in the project before. I got it updated via nuget. I do remember though that the version of dll that had it working was a 2.[something].
Coordinator
Mar 8, 2013 at 2:28 AM
That doesn't sound right as T4MVC didn't have a DLL at all until v3.0. And even now that it does, all the logic relevant to this issue is in the .tt file. Can't you just look in your source control what version you were on before?
Mar 8, 2013 at 2:39 AM
yeah, sorry, you are right. It was not a dll. The version I recall was coming from the information pane on nuget. I'll be able to look which version that was tomorrow when I get to work. I don't have access to that project from home.
Mar 8, 2013 at 5:31 PM
The version that had it working was 2.10.1
Coordinator
Mar 8, 2013 at 6:00 PM
I just tried 2.10.1 and don't see that working either.

But I think I may know the reason. Maybe in 2.10.1 you had a custom T4MVC.tt.settings.t4 where you had added that folder in the StaticFilesFolders. In recent versions, those settings moved to T4MVC.tt.settings.xml, so you may have to customize that accordingly.
Mar 8, 2013 at 6:07 PM
You are right. That's it! However now I'm thinking that this could actually be a nice feature to make T4MVC look for the folders that are named the same (defaults Scripts and Content) under all Areas if IncludeAreasToken is true. I see a complication here though. Areas could be called whatever... will T4MVC be able to find them all?
Coordinator
Mar 8, 2013 at 6:10 PM
There are other places where T4MVC looks for Areas (for controllers & views), so I think it could be done. It just takes someone to want it enough to do it and send a pull request :)
Mar 8, 2013 at 6:14 PM
I like your approach :)
Coordinator
Mar 8, 2013 at 6:23 PM
Yeah, unfortunately, I have had very little time myself to work on T4MVC lately. But luckily, we have been getting a lot of good contributions, which have helped move the project forward.