The example below might be clearer - I want to use an inline razor macro, and depending on the node type, either render a razor or xslt macro. Works fine for the if condition, but the else renders the macro alias
The argument to RenderMacroContent() is not the macro alias - it was intended for use with a bodyText (RTE) field containing on or more macros inserted fomr the GUI.
@RenderPage equivalent for xslt
I'm trying to render an xslt macro from within an inline razor macro - is this even possible?
I thought using the following would work:
But apparantly not - the output is 'macroAlias'
I'm using xslt to build the navigation, which I want to display conditionally from within a razor macro - if it was all razor I'd use @RenderPage()...
Any ideas?
Nathan
Hi Nathan,
I'm not really sure what you're wanting to achieve but this might help http://our.umbraco.org/wiki/reference/umbracolibrary/rendermacrocontent
Rich
Just re-read that, you're trying to render an XSLT macro from Razor, I have no idea if this can be done.
Rich
Hi Rich
The example below might be clearer - I want to use an inline razor macro, and depending on the node type, either render a razor or xslt macro. Works fine for the if condition, but the else renders the macro alias
<div id="leftContentContainer">
<umbraco:macro runat="server" language="cshtml">
@{
if (Model.NodeTypeAlias == "LandingPage") {
@RenderPage("~/macroScripts/Sidebar.cshtml)
}
else {
<nav id="navigationContainer" role="complementary">
@Html.Raw(umbraco.library.RenderMacroContent("xsltNavigation", Model.Id))
</nav>
}
}
</umbraco:macro>
</div>
Hi Nathan,
The argument to RenderMacroContent() is not the macro alias - it was intended for use with a bodyText (RTE) field containing on or more macros inserted fomr the GUI.
You should probably be able to do this then:
I'm not sure about the quote-escaping in Razor, but I think you should be able to get it right.
/Chriztian
Chriztian - that works perfectly. I though I'd tried something along those lines, must have just missed the mark. Thanks for the advice.
N
is working on a reply...