Macro Stopped Working After Upgrading to Version 6.0.0
Hi all,
below is a piece of code I use to get some Facebook albums presented in my website:
int i = 0; <div class="grid-content-940"> @foreach (Album album in Facebook.GetAlbums(facebookUserID)) { var testAlbumID = @album.ID; if (!excludedAlbums.Contains(testAlbumID)) { i++; <div class="grid-content-220"> <div class="album-row-holder"> <div class="album-box-out"> <div class="album-box-in"> <a href="/portfolio/album/@album.ID"> <img src="@CreateThumbnail(@album.CoverPhoto, 174, 118)" alt="@album.Name" /> </a> </div> </div> </div> <div class="read-more"> <a href="/albumid/@album.ID">@album.Name</a> [@album.Count] </div> </div> if ((i % 4) == 0) { <div class="grid-separator-row"></div> } else { <div class="grid-separator-18"></div> } } } </div>
While the code above works on a 4.11.4 test installation, I cannot make it work on a 6.0.0 installation. The parser keeps telling me that a } is expected. The weird thing is that if I comment the if statement in line 6 with the respective {} braces in lines 7 & 25, everything works fine!
@Charles Afford: I know that using such spaghetti code, is not the best approach, but right now it's the best we can do...! As I've already mentioned, the code above works fine in Umbraco 4.11.4.
@Steven Lemmens: I tried the modification suggested, but it gives me the following error:
Unexpected "if" keyword after "@" character. Once inside code, you do not need to prefix constructs like "if" with "@".
I really have no idea what's going on, but I'd like to thank you all for your help.
after some digging and testing, I decided to move the "exclusion" login into my assembly, so now the "GetAlbums" function includes the "if" statement. The code gets saved correctly and the macro runs with no problem.
Ioannis. i understand, it depends what you are doing it for.? The problem you will run into is builiding layers on top of that spag code, that will not be easy if at all possible to undo in the future. Any how i am glad you solved your problem :) Charles.
i had this issue too when moving from 4.11.3 to 6.0.0. Many Razor scripts were throwing errors like you mentioned. Version 6.0.0 handles the "@" sign very sensitively ;-)
Some background information: the change was mentioned in this blog post: "...The upgrade to MVC4 and therefore Razor 2.0 leads to stricter checking of misplaced @ signs. For details, issue 1143."
Macro Stopped Working After Upgrading to Version 6.0.0
Hi all,
below is a piece of code I use to get some Facebook albums presented in my website:
While the code above works on a 4.11.4 test installation, I cannot make it work on a 6.0.0 installation. The parser keeps telling me that a } is expected. The weird thing is that if I comment the if statement in line 6 with the respective {} braces in lines 7 & 25, everything works fine!
Any ideas?
Thanks in advance,
Hi, what language are you using? surely
{
HTML MARKUP
}
is going to through an error?
Charlie :)
Have you tried putting an explicit @ in front of the "if ((i % 4) ..." part to make sure it parses as code again?
Hi all,
@Charles Afford: I know that using such spaghetti code, is not the best approach, but right now it's the best we can do...! As I've already mentioned, the code above works fine in Umbraco 4.11.4.
@Steven Lemmens: I tried the modification suggested, but it gives me the following error:
Unexpected "if" keyword after "@" character. Once inside code, you do not need to prefix constructs like "if" with "@".I really have no idea what's going on, but I'd like to thank you all for your help.
Hello again,
after some digging and testing, I decided to move the "exclusion" login into my assembly, so now the "GetAlbums" function includes the "if" statement.
The code gets saved correctly and the macro runs with no problem.
Thanks a lot again, all of you!
Ioannis. i understand, it depends what you are doing it for.? The problem you will run into is builiding layers on top of that spag code, that will not be easy if at all possible to undo in the future. Any how i am glad you solved your problem :) Charles.
Hi,
i had this issue too when moving from 4.11.3 to 6.0.0. Many Razor scripts were throwing errors like you mentioned.
Version 6.0.0 handles the "@" sign very sensitively ;-)
It could be this line:
Try to leave the "@" here.
Matthias
Hi all,
although I have moved the exclusion logic into my assembly I tried Matthias's solution and it really works!
As he said the @ sign is handled very sensitively...
Anyway, thanks again all of you!
Some background information:
the change was mentioned in this blog post: "...The upgrade to MVC4 and therefore Razor 2.0 leads to stricter checking of misplaced @ signs. For details, issue 1143."
is working on a reply...