Copied to clipboard

Flag this post as spam?

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


  • Michiel 137 posts 294 karma points
    Oct 14, 2011 @ 12:48
    Michiel
    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.

     

  • Michiel 137 posts 294 karma points
    Oct 14, 2011 @ 12:53
    Michiel
    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 1505 posts 5911 karma points MVP 4x 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.

  • 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