I am just starting to use awesome Razor for my umbraco macro control and have weird errors that puzzled me until now.
I am using umbraco 4.6.1 Juno and uCompnents referenced. The Top navigation snippet below is the one I got from Umbraco Wiki.
Screenshot of the errors.
The code looks correct to me and I put the macro in the HomeMaster.master template. It seems that it the code fails when calling the Node.GetCurrent() method. (I tried the other samples using uQuery methods and they gave me the same error. Using the dynamic nodes samples are working fine?
There's also some difficulty in saving the razor files after I had the error. (e.g.Changing the whole razor code above to <h1>@Model.Name</h1> will only work after app_pool restart).
Any ideas about this error? Has anyone encountered the same issue before?
It looks like @Jonas Eriksson, @Ismail Mayat and the rest have no problem implementing their Macro in Razor? Any tips on how do you implement your Razor macro?
Hi William,
Umbraco 4.7beta has a better Razor engine than 4.6 - and most newer forum posts comes from people using 4.7beta. But your code should work if you simply check the 'skip testing' checkbox. It's the code editor syntax checker that fails because there's no current node at that time.
Regards
Jonas
Yup, I second that. I have been working with the nightlies leading up to 4.7beta and can quite confidently say that 4.7beta is a much better version than 4.6.1.
The new Razor implementation differs quite a bit from 4.6.1 and is the way forward. If you want to play with Razor and are not going to go live in the next few weeks then I can recommend and upgrade. Make sure to compare your /config/*.config files to the newer versions (espcially umbracoSettings.config) and make sure to add the additional "4.6.2" bits to your web.config.
Yes right, one liner if's does not work - they did with the previous (4.6) parser tho. I tried to update the wiki, but there's some bug stopping it from displaying the latest version. hm.
Don't know why but we're switching from a custom parser implementation to the official one (the one also used in Webpages) and that might be why (all the if razor examples I've seen has curly braces around them).
Razor Errors
Hi all,
I am just starting to use awesome Razor for my umbraco macro control and have weird errors that puzzled me until now.
I am using umbraco 4.6.1 Juno and uCompnents referenced. The Top navigation snippet below is the one I got from Umbraco Wiki.
Screenshot of the errors.
The code looks correct to me and I put the macro in the HomeMaster.master template. It seems that it the code fails when calling the Node.GetCurrent() method. (I tried the other samples using uQuery methods and they gave me the same error. Using the dynamic nodes samples are working fine?
There's also some difficulty in saving the razor files after I had the error. (e.g.Changing the whole razor code above to <h1>@Model.Name</h1> will only work after app_pool restart).
Any ideas about this error? Has anyone encountered the same issue before?
It looks like @Jonas Eriksson, @Ismail Mayat and the rest have no problem implementing their Macro in Razor? Any tips on how do you implement your Razor macro?
For now I am back using the plain usercontrol :(.
Thanks.
Hi William,
Umbraco 4.7beta has a better Razor engine than 4.6 - and most newer forum posts comes from people using 4.7beta.
But your code should work if you simply check the 'skip testing' checkbox. It's the code editor syntax checker that fails because there's no current node at that time.
Regards
Jonas
Yup, I second that. I have been working with the nightlies leading up to 4.7beta and can quite confidently say that 4.7beta is a much better version than 4.6.1.
The new Razor implementation differs quite a bit from 4.6.1 and is the way forward. If you want to play with Razor and are not going to go live in the next few weeks then I can recommend and upgrade. Make sure to compare your /config/*.config files to the newer versions (espcially umbracoSettings.config) and make sure to add the additional "4.6.2" bits to your web.config.
One thing about your code though: You have to use parenthesis in an "if" statement, so you need to wrap your "css=..." in some curlies { }
Yes right, one liner if's does not work - they did with the previous (4.6) parser tho. I tried to update the wiki, but there's some bug stopping it from displaying the latest version. hm.
Don't know why but we're switching from a custom parser implementation to the official one (the one also used in Webpages) and that might be why (all the if razor examples I've seen has curly braces around them).
Okay, good to know, just did a quick Google search and indeed this is due to the official implementation, thanks!
Thanks for the replies guys
is working on a reply...