I'm slightly obsessive about the readability (and hence indentation) of all markup.
When I call @Styles.Render("~/content/css")
in an ASP.NET MVC4 project, only the first line maintains indentation from my Razor template.
Here is the output:
<link href="/Content/css/ie.css" rel="stylesheet"/>
<link href="/Content/css/1140.css" rel="stylesheet"/>
<link href="/Content/css/screen.css" rel="stylesheet"/>
<link href="/Content/css/compatibility.css" rel="stylesheet"/>
I would prefer all generated markup have the same indentation as the @Styles.Render()
call.
Is this easily done? If so, how?
Ideally the rendered HTML would be minified. Formatted markup is great while developing but makes for a bigger file if that is what you are serving to the user.
The only reason you see four style sheets is that you are running in a debug environment, which has disabled your bundling. As I explained in the post "Scripts.Render using outdated javascript file" if you add
BundleTable.EnableOptimizations = true;
to the bottom of yourRegisterBundles
in yourBundleConfig
, it will force bundling to work (as it would in release mode), and you'll see that this:now renders as this:
So yes while developing, it isn't maintaining your indentation, but once you publish it will be what you want.