Copied to clipboard

Flag this post as spam?

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


  • Umbraco 137 posts 294 karma points
    Oct 14, 2011 @ 12:48
    Umbraco
    0

    How can render a Razor macro from an inline Razor macro (in a loop)?

    Starting with this code in a regular template (.master file):

    <umbraco:Macro runat="server" language="cshtml">

    @foreach(var node in Model.Children) {

    @RenderPage("~/macroScripts/partial.cshtml", node)

    }

    </.umbraco:Macro>

    Even though I am passing each child node through, the Model property in the partial is still the parent node, not the child node.

     

  • Umbraco 137 posts 294 karma points
    Oct 14, 2011 @ 12:53
    Umbraco
    0

    Nevermind, I should read the wiki, then I would have found this:

    http://our.umbraco.org/wiki/reference/code-snippets/razor-snippets/@renderpage-with-args

     

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Oct 14, 2011 @ 14:22
    Dan Diplo
    0

    Don't forget you can also use Razor helpers (@helpers) with Umbraco - just put your helper code in App_Code.

Please Sign in or register to post replies

Write your reply to:

Draft