Copied to clipboard

Flag this post as spam?

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


  • Jason N 55 posts 79 karma points
    May 09, 2011 @ 22:45
    Jason N
    0

    Output macro in Razor script

    I'd like to output a macro from inside a razor script.  If I use the macro declarations then I end up opening and closing Razor macro tags all over the page to allow for the other macro tags.  I've tried the following but haven't got it to work so far.

    @{ var faceBookMacro = new umbraco.presentation.templateControls.Macro(){Alias = "FacebookFeed"};
     faceBookMacro.MacroAttributes.Add("FacebookId", "13412341");
     faceBookMacro.RenderControl(new HtmlTextWriter(Response.Output));
    }

    Any ideas?  It'd be awesome if we had some simple razor syntax for doing this.

  • Richard Boelen 61 posts 153 karma points
    May 28, 2011 @ 15:46
    Richard Boelen
    0

    Can you try something like this:

    @Html.Raw(umbraco.library.RenderMacroContent(Model.macro, Model.Id));
    
    In this case Model.macro is a MacroContainer datatype on your DocumentType
    Cheers, Richard

     

Please Sign in or register to post replies

Write your reply to:

Draft