Copied to clipboard

Flag this post as spam?

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


  • Dennis Knappe 2 posts 22 karma points
    Jul 01, 2011 @ 20:50
    Dennis Knappe
    0

    How to get macro parameters inside IronRuby

    Hi there,

    I've created a very simple IronRuby script, and added a macro on top of it.

    The script works fine and renders nicely on my page. Now I have added a couple of parameters to my macro.

    - LanguageId (number)
    - Headline (text)

    How do I retrieve them inside my IronRuby script? I have tried $LanguageId, @LanguageId but no luck!

    In IronPython it's possible with:

    if globals().has_key("LanguageId"):
      languageId = int(LanguageId)

    /Dennis

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Jul 02, 2011 @ 13:00
    Jan Skovgaard
    0

    Hi Dennis

    I'm not really a programmer myself but I got curious about this when I saw your post so I tried to google a bit and maybe I found something...

    I'm not sure...but could this be what you're after? http://webcache.googleusercontent.com/search?q=cache:K7uxCPkWqaoJ:wwww.umbraco.org/forum/developers/extending-umbraco/13698-IronRuby-and-Umbraco+umbraco+ironruby+get+parameter&cd=2&hl=da&ct=clnk&gl=dk&client=firefox-a&source=www.google.dk#comment50617

    All the best.

    /Jan

  • Dennis Knappe 2 posts 22 karma points
    Jul 02, 2011 @ 14:10
    Dennis Knappe
    0

    Hi Jan,

    Thanks for your reply. Your link got me on the right track. It seems that changing the macro parameter aliases to a more RUBY'ish name will do the trick. I changed the names to:

    - language_id
    - headline

    Now I can read them inside IronRuby (highfive). They are just normal variables without any prefixes.

    Let's say you want to write out a headline:

    puts "<h1>#{headline}</h1>"

    ---

    If my macro parameter name is LanguageId it seems impossible to read it from IronRuby. I have tried various combinations without any luck:

    LanguageId
    LanguageID
    Languageid
    languageId
    languageID
    languageid
    Language_Id
    Language_ID
    Language_id
    language_Id
    language_ID
    language_id

    If anyone knows why please leave a message - it could be great to know why :-)

    /Dennis

  • 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