Copied to clipboard

Flag this post as spam?

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


  • Zac 239 posts 541 karma points
    Mar 31, 2012 @ 00:15
    Zac
    0

    Umbraco 5 - Render a macro from dynamic parameters (both property name and value are dynamic)

    Hi All,

    I'm trying to dynamically create a macro via a string of macro parameters and can't figure out how to do this:

    I know you can add a macro to a template via the @Umbraco.RenderMacro(id, new {Parameter="ParamValue", Param2="ParamValue2" }) but I'm looking to create the macro via the macro id and either dynamic macro parameters or a dictionary of parameters.

    For example, I'll have a macro Id and an input string that will contain "Parameter='ParamValue'" and would like to pass this in to render the macro.
    I could easily pass in a dictionary directly to the RenderMacro helper, but one of the first steps converts the object params to a dictionary and this fails if I pass in a dictionary directly.
    Any ideas on how to achieve this?
    Background.  I have a custom property editor that allows macros to be added to it and need to render this data with the rendered macros to the end user.
    Thanks
Please Sign in or register to post replies

Write your reply to:

Draft