Reputation: 4830
I am using ASP.NET-MVC, and would like to format my html prior to sending it to the browser.
I have one page with multiple partialviews, and i want it all to be indented nicely.
I know this is stupid, but while in development it's nice to have well formatted html when you go: RightClick -> View Source.
Does anyone know of a way to do this?
Upvotes: 1
Views: 292
Reputation: 15663
You can either inject code that gets executed every single request, with attendant risks or overhead. Or you could get better tools.
Upvotes: 0
Reputation: 5962
Have a look at this blog post: ASP.NET MVC clean HTML
I think it's exactly what you're looking for. The author uses ActionFilter
s and Tidy.NET to format the HTML output.
Upvotes: 2
Reputation: 1109570
In Java, there the HTML Tidy/JTidy is for. There are ports available in PHP and ASP.NET as well.
Upvotes: 0
Reputation: 21905
I don't know if this is possible - it certainly does not seem practical - it would be a lot of formatting work on every page when you will only occasionally use view source.
I would suggest selecting a different text editor to do your view source, and then use the editor's formatting tools to format the html. I use TextPad and while the html formatting isn't fabulous, it does help. I am sure there are other editors you could try for this.
Upvotes: 1