Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • William Djingga 27 posts 53 karma points
    Feb 25, 2011 @ 00:37
    William Djingga
    0

    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.

     

     

     

     

     

     

     

  • Jonas Eriksson 930 posts 1825 karma points
    Feb 25, 2011 @ 03:49
    Jonas Eriksson
    0

    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

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Feb 25, 2011 @ 07:54
    Sebastiaan Janssen
    0

    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.

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Feb 25, 2011 @ 07:58
    Sebastiaan Janssen
    0

    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 { }

     

  • Jonas Eriksson 930 posts 1825 karma points
    Feb 25, 2011 @ 08:10
    Jonas Eriksson
    0

    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.

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Feb 28, 2011 @ 11:51
    Niels Hartvig
    0

    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).

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Feb 28, 2011 @ 12:15
    Sebastiaan Janssen
    0

    Okay, good to know, just did a quick Google search and indeed this is due to the official implementation, thanks!

  • William Djingga 27 posts 53 karma points
    Mar 04, 2011 @ 07:25
    William Djingga
    0

    Thanks for the replies guys

Please Sign in or register to post replies

Write your reply to:

Draft