4

I'm starting to make heavy use of T4MVCs "links" feature (eg, @Links.Content.Site_css). Does anyone know if there's a way to generate methods for files that are stored in folders within areas? I've tried making the following modification to the settings file, but haven't had any luck.

// Folders containing static files for which links are generated (e.g. Links.Scripts.Map_js)
readonly string[] StaticFilesFolders = new string[] {
"Scripts",
"Content",
"Areas/Admin/Content"
};

Thanks very much in advance.

DS

Damien Sawyer
  • 5,323
  • 3
  • 44
  • 56

2 Answers2

5

Instead of

"Areas/Admin/Content"

Try using:

@"Areas\Admin\Content"

I think this will do it.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • Thanks David. Alas, no joy. Firstly, the generated code clashed with the main ~/Content directory. So, I renamed the admin path to "Areas/Admin/ContentAdmin". Then T4MVC created 'private const string URLPATH = "~/ContentAdmin";' - ignoring the areas/admin paths. It's not a big deal, but thanks for your help. While I've got you here - thanks for a fantastic tool! It really lifts the whole MVC experience. :-) – Damien Sawyer Oct 24 '11 at 09:37
  • Ah yes, looking at the code in ProcessStaticFiles, I think I see why it's busted. It's likely fixable if you feel like taking a crack at it. Basically, it should just pass "~" to ProcessStaticFilesRecursive when the folder is deeper, or something like that. Sorry, things are a bit crazy here so I'm not sure I can get to it too soon. – David Ebbo Oct 25 '11 at 04:37
  • Thanks David. I'll stick it on the list to have a look at and post any results here. – Damien Sawyer Oct 25 '11 at 21:45
  • +1 T4Mvc must have been updated since then, this worked for me – Maslow Feb 19 '13 at 15:29
3

I didn't end up needing to alter T4MVC.TT at all. Adding "Areas" to the StaticFilesFolders in T4MVC.TT.settings.T4 did the trick.

// Folders containing static files for which links are generated (e.g.            Links.Scripts.Map_js)
readonly string[] StaticFilesFolders = new string[] {
"Scripts",
"Content",
"Areas"
};

Thanks for your help David. :-)

PS - using T4MVC Version 2.6.64

Damien Sawyer
  • 5,323
  • 3
  • 44
  • 56