1. In Visual Studio, create a Razor v2 web site.
2. Copy and paste the following code into one of the content pages:
@{
//Check there are slider image page loaded
var theCount = @Model.Descendants("SliderImagePage").Count();
if (theCount > 0)
{
foreach (var theImagePage in Model.Descendants("SliderImagePage"))
{
var theImage = theImagePage.Media("sliderImage","umbracoFile");
if (theImagePage.IsFirst())
{
@:<div class="slide" style="background-image:url('@Html.Raw(theImage)');display:block;"></div>
} else {
@:<div class="slide" style="background-image:url('@Html.Raw(theImage)');display:none;"></div>
}
}
}
else
{
@: No Picture Image pages set up
}
}
(Note: The above code compiles without error in Razor v1.)
3. Attempt to build the site.
Result: The site will fail to compile with multiple errors. Scrutinizing the errors , reporting that the @: expression on line 11 requires a keyword, identifier, or string, and that the subsequent '}' character on line 12 closes the code block that began on line 1. If a user removes the "@" character on line 3 of the code snippet, the compilation proceeds without error.
Expected: The code snippet above should compile as it would have in Razor v1.
Comments: We haven't heard any user feedback on this. If we hear more about it, or if you believe it's important feel free to reopen.
2. Copy and paste the following code into one of the content pages:
@{
//Check there are slider image page loaded
var theCount = @Model.Descendants("SliderImagePage").Count();
if (theCount > 0)
{
foreach (var theImagePage in Model.Descendants("SliderImagePage"))
{
var theImage = theImagePage.Media("sliderImage","umbracoFile");
if (theImagePage.IsFirst())
{
@:<div class="slide" style="background-image:url('@Html.Raw(theImage)');display:block;"></div>
} else {
@:<div class="slide" style="background-image:url('@Html.Raw(theImage)');display:none;"></div>
}
}
}
else
{
@: No Picture Image pages set up
}
}
(Note: The above code compiles without error in Razor v1.)
3. Attempt to build the site.
Result: The site will fail to compile with multiple errors. Scrutinizing the errors , reporting that the @: expression on line 11 requires a keyword, identifier, or string, and that the subsequent '}' character on line 12 closes the code block that began on line 1. If a user removes the "@" character on line 3 of the code snippet, the compilation proceeds without error.
Expected: The code snippet above should compile as it would have in Razor v1.
Comments: We haven't heard any user feedback on this. If we hear more about it, or if you believe it's important feel free to reopen.