Minify HTML contained in the view

Feb 19, 2011 at 1:08 AM
Edited Feb 19, 2011 at 1:19 AM

Hi, first i'm a big fan of your ostrich :). I was reinventing the wheel when I found your project. The only thing that miss me is the ability to minify the html of the view in your ViewEngine, just after the inline style/script minification.

I've done that in a post-build task but it would be awsome to have that in your project.

The only trick is to fix some pecularities of Razor/WebForm Syntaxes: So far, I had to fix the view typing and the block syntax : they both need a carriage return character.

Something like that :

//fix @model
viewText = Regex.Replace(viewText, @"(@model\s+\S+\s*)", "$1\r");
//fix @{ }
viewText = Regex.Replace(viewText, @"(@{(\s)*[^}]*}\s*)", "$1\r");

And it works great :)


Jun 1, 2011 at 7:31 AM

This feature would be awesome!