Copied to clipboard

Flag this post as spam?

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


  • Dima Stefantsov 100 posts 225 karma points
    Apr 19, 2013 @ 17:19
    Dima Stefantsov
    0

    Render Macro by alias from Razor code

    Hi. I'm using Umbraco 6.0.3, WebForms. My macros have razor code. I want to insert other macro's output into first macro. There are different ways of doing it:

    1. http://stackoverflow.com/questions/10689284/umbraco-render-net-user-control-ascx-macro-with-razor (would not honor caching settings, I believe)

    2. https://github.com/tocsoft/Umbraco-Razor-Components (this one explicitly looks for Cache, that's why I believe it will work)

    3. Use filename like @RenderPage("~/Views/Partials/uBlogsy/Post/uBlogsyPostListLabels.cshtml", new { Node = node }) (it will not honor backend macro settings and looks like a bad practice anyway)

    4. http://incoders.blogspot.ru/2011/10/render-macro-umbraco-exmaple.html
    This one actually works! And I am going to use it for now (or I'll stick to using razor @helpers since my current task is pretty lightweight). But it totally looks like a hack. Isn't there some built-in Umbraco method to render macro from razor?

  • Dan Evans 631 posts 1018 karma points
    Sep 26, 2013 @ 12:18
    Dan Evans
    0

    A very good question. Did you get an answer? I need to render a razor script from within a razor script precisely because i want different caching on each script. Did you find option 2 to work?

    Thanks

    Dan

Please Sign in or register to post replies

Write your reply to:

Draft