Comments (9)
@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.
from html-minifier.
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.
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.
Can anyone attach a sample file to reproduce the error?
Then we can add that file to the UnitTests...
from html-minifier.
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.
Thanks @Deutschi
what would be the correct output on those examples?
from html-minifier.
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.
This issue should be fixed with the latest release!
from html-minifier.
@deanhume
I don't think this has been fixed yet...
from html-minifier.
Related Issues (20)
- problems with html files that contain unicode characters HOT 3
- Option to minify single file HOT 2
- Html conditional comment - opening and closing in two tags HOT 1
- Razor error comments "//" in @{} HOT 6
- <input type="file" accept="image/*" name="files[]" multiple> HOT 4
- Content of <pre> tag should not be minified
- Razor text mode does not minify properly HOT 2
- minify js file encode error HOT 1
- Issue with accents in words HOT 1
- end of statement expected error with @imports HOT 1
- Regex issue with javascript line comments HOT 1
- wrong encoding for turkish characters HOT 2
- Dictionary as Razor model
- var test = "1";// COMMENT HOT 3
- Multiple * Bug HOT 2
- utf8 HOT 1
- c# comment "//" on razor view cannot be ignored
- Encoding error for accept tag in input type file. HOT 1
- HtmlMinifier in Toll folder says it's a 16 bit app HOT 1
- DELETED HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from html-minifier.