deanhume / html-minifier

A simple command line tool to minify your HTML, Razor views & Web Forms views
http://deanhume.github.io/html-minifier/
MIT License
134 stars 86 forks source link

Minification problem when using @inherits ...<> #13

Closed 06b closed 9 years ago

06b commented 9 years ago

Since I'm using Nancy with Razor, I have to add @inherits Nancy.ViewEngines.Razor.NancyRazorViewBase to the top of each view in order to enable intellisense (it appears to work without being on the top of each view, but I believe this is common to those who use Nancy with Razor to place it at the top)

Similar to issue #10 I believe it's due to the fact it ends with >

As a temporary workaround I've moved the code>@Inherits</code section to the very bottom of the view.

deanhume commented 9 years ago

Would it be possible for you to post a sample of your view and I'll update the tests....

06b commented 9 years ago

Sure, below's a generic error view

@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<dynamic>
@{
    Layout = "Views/Shared/_Layout.cshtml";
}

<h1>Looks like something went wrong.</h1>

<p>Sorry, we are experiencing technical difficulties. We are working on getting this problem resolved. Sorry for any inconvenience!</p>

Also not sure if it matters - but the master layout might also include the @inherits on the top as well.

deanhume commented 9 years ago

Hi @06b - this has been fixed in the latest release. Let me know how it goes for you!

https://github.com/deanhume/html-minifier/releases/tag/v1.4

06b commented 9 years ago

Hey @deanhume - I haven't had a chance to fully look into this however it looks like I'm still having some issues (however it could be due to something else I'm doing with the project I'm currently using the html minifier on - I'll try creating a new project sometime this week to confirm that this issue is fixed)

I noticed when I was quickly looking over the commit for the fix that the GithubIssue13Result.txt file seems to be missing from the HtmlMinifier.Tests/Data folder, just as an fyi.

06b commented 9 years ago

Hey @deanhume - So did some testing, the Minifier does in fact work however it appears the issue is that when @inherits is being used - it errors out if another @ ends up following it on the same line.

So if I did @inherits followed by @{ Layout = ""} or @using - it will cause the it to not render - The work around I could foresee would be if @inherits is used after the > to perhaps do a new line. For all I know, this could of been the issue all alone, I just assumed it was the same issue as 10 but I could of been wrong.