Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I am getting stuck in to Base Extensions, but can't find any way to render a razor macro and return the html.
I have so far looked at the umbraco.library.RenderTemplate() and RenderMacroContent() methods , but these don't apply to razor.
Also tried macro.GetMacro() attempting to parse it myself, where I can get the name of the razor macro, but the MacroContent element is empty.
I am using Umbraco 4.8.0
Help!
Mark.
Why do you want to render a macro from base ?
dave
I want to reuse some widgets that we have on one site in another site we are building.
The idea is to not duplicate the "templating".
We want the flexibility of having:
I managed to get it done! (Eventually falling over this code snippet http://our.umbraco.org/wiki/reference/code-snippets/razor-snippets/render-razor-scripts-for-emails-and-more)
Hope this can help someone else in the same situation...
using umbraco;
using umbraco.MacroEngines;
using umbraco.cms.businesslogic.macro;
public static string GetOffer(int nodeId)
{
var macroEngine = new RazorMacroEngine();
MacroModel model = new MacroModel();
model.ScriptCode = "";
model.ScriptLanguage = "cshtml";
model.ScriptName = "OfferList.cshtml";
return macroEngine.Execute(model, new umbraco.NodeFactory.Node(nodeId));
}
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Render razor macro from a base extension
Hi,
I am getting stuck in to Base Extensions, but can't find any way to render a razor macro and return the html.
I have so far looked at the umbraco.library.RenderTemplate() and RenderMacroContent() methods , but these don't apply to razor.
Also tried macro.GetMacro() attempting to parse it myself, where I can get the name of the razor macro, but the MacroContent element is empty.
I am using Umbraco 4.8.0
Help!
Mark.
Why do you want to render a macro from base ?
dave
I want to reuse some widgets that we have on one site in another site we are building.
The idea is to not duplicate the "templating".
We want the flexibility of having:
Mark.
I managed to get it done! (Eventually falling over this code snippet http://our.umbraco.org/wiki/reference/code-snippets/razor-snippets/render-razor-scripts-for-emails-and-more)
Hope this can help someone else in the same situation...
is working on a reply...