Copied to clipboard

Flag this post as spam?

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


  • Rune Grønkjær 1303 posts 2895 karma points
    Aug 12, 2010 @ 10:37
    Rune Grønkjær
    0

    Macro naming best practice

    Hi,

    As some may know macro parameters cannot be named the same as some standard ASP.NET parameters. You can eg. not call a macro parameter "cssClass", as it will not work. My problem is that this is what I want to call it and I may have an ok solution.

    How about calling it "_cssClass"? To hold a certain consistancy I suggest we allways insert the underscore at the beginning of parameter names. This would also make sure that MS won't make up new parameters possibly rendering one of our parameters of the same name useless.

    Any ideas/comments on this?

    /Rune

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Aug 12, 2010 @ 10:52
    Chriztian Steinmeier
    0

    Hi Rune,

    I'm not fond of that - parameters end up as elements in the document sent to the XSLT file. XML elements that start with an underscore are not my cup of tea (though it seems like it's valid):

    <macro>
            <_cssClass>selected</_cssClass>
            <!-- etc. -->
    </macro>

    I tend to use a prefix that makes sense for the current context/project, e.g. "vimeoVideoLink", "navSelectedClass" etc.

    /Chriztian

  • Rune Grønkjær 1303 posts 2895 karma points
    Aug 12, 2010 @ 10:57
    Rune Grønkjær
    0

    Hi Chriztian,

    Yes i sertainly see your point. My problem is that a css class is a class no matter what the use. It would be nice for me to have a standard so when I wantet the css class from anyone of my macros their names would allways be the same, no matter the context.

    Now, I could just call them umbracoCssClass, but I think that name is too long.

    /Rune

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies