GithubHelp home page GithubHelp logo

Comments (9)

0xApp avatar 0xApp commented on August 23, 2024

@walterDurin consider using

@if (true){
    <text> you content here,
         some more content here
    </text>
}

The tag is an element that is treated specially by Razor. It causes Razor to interpret the inner contents of the block as content, and to not render the containing tag element (meaning only the inner contents of the element will be rendered – the tag itself will not). This makes it convenient when you want to render multi-line content blocks that are not wrapped by an HTML element.

Check this

from html-minifier.

ConcatenatedNonsense avatar ConcatenatedNonsense commented on August 23, 2024

Just tried the Minifier on the release code version of an existing project and the site errored outright on load.

Event Viewer shows that it failed at the first @if statement inside the minified code.

from html-minifier.

heldersepu avatar heldersepu commented on August 23, 2024

Look here:
https://github.com/deanhume/html-minifier/blob/master/ViewMinifier/StreamReaderExtension.cs#L54
I believe all we need to do is add a line:
declarations.Add("@if ", false);

from html-minifier.

heldersepu avatar heldersepu commented on August 23, 2024

Can anyone attach a sample file to reproduce the error?
Then we can add that file to the UnitTests...

from html-minifier.

Deutschi avatar Deutschi commented on August 23, 2024

Example 1:

Input:

<div>
    @if (true)
    {
        @: this is normal text without html tag
    }
</div>

Output:

<div> @if (true) { @: this is normal text without html tag } </div>

The closing "}" is no longer recognized as syntax, because it's on the same line as the "@:"

Example 2:

Input:

<div>
	@switch (foo)
	{
		default:
			@: @Model.Name
			break;
	}
</div>

Output:

<div> @switch (foo) { default: @: @Model.Name break; } </div>

The "break" is no longer recognized as syntax, same as example 1.

from html-minifier.

heldersepu avatar heldersepu commented on August 23, 2024

Thanks @Deutschi
what would be the correct output on those examples?

from html-minifier.

Deutschi avatar Deutschi commented on August 23, 2024

Valid output:

<div> @if (true) { @: this is normal text without html tag
} </div>
<div> @switch (foo) { default: @: @Model.Name
break; } </div>

Suggestion: The next line break after an "@:" should not be replaced.

from html-minifier.

deanhume avatar deanhume commented on August 23, 2024

This issue should be fixed with the latest release!

from html-minifier.

heldersepu avatar heldersepu commented on August 23, 2024

@deanhume
I don't think this has been fixed yet...

from html-minifier.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.