Is there a way to render a macroScript direclty with the filename in a *Razor View*? I see there's a way to do it with master pages, but can't figure it out with Razor templates...
if you take the macro out, put the code into a partial view, then call @Html.Partial("yourPartialName") you should be cooking with gas, fhat is if you are using mvc.
if webforms, its.a.macroscript i believe, but you should be able to call direct from the file.
Yes, I discovered that... But then I discovered that a ton of code changes were required to go from a simple Razor macro to a Partial View! Things like having to use "Model.Content.Field" vs. "Model.Field" and for some reason having to use "mntp.link.InnerText()" where just "mntp.link" worked fine with the Razor macro. It's a whole new world with MVC, but I am excited that I can add some logic to my template generation... it's pretty cool and a real boon for responsive design!
some of what you say is true, but those code changes are due mainly to changes in the version of umbraco.
The code used in a normal mvc view is exactly the same as you would use in your partial, so take your whole view, make the partial from that code and call the partial from the original view and it will work.
I use this to make my partials, write the code in the view, if the code will be repeated elsewhere, then create the partial, cut the code block, paste into the partial and call the partial in the orignal view and wherever else it is needed.
Hope that helps, dive in, give it a try and you can leave macros behind.
It does help... just confused by some of the new things i didn't know about like calling objects with ".AsDyanmic()" and such... Yeah, I am sick of having dozens of macros to do simple things like change headines on the fly, navigation, etc. Gets confusing. Already enjoying the more integrated and structurally solid MVC way...
Render Razor Macro Directly in Razor View?
Is there a way to render a macroScript direclty with the filename in a *Razor View*? I see there's a way to do it with master pages, but can't figure it out with Razor templates...
hi Robert
if you take the macro out, put the code into a partial view, then call @Html.Partial("yourPartialName") you should be cooking with gas, fhat is if you are using mvc.
if webforms, its.a.macroscript i believe, but you should be able to call direct from the file.
hope it helps
g
Yes, I discovered that... But then I discovered that a ton of code changes were required to go from a simple Razor macro to a Partial View! Things like having to use "Model.Content.Field" vs. "Model.Field" and for some reason having to use "mntp.link.InnerText()" where just "mntp.link" worked fine with the Razor macro. It's a whole new world with MVC, but I am excited that I can add some logic to my template generation... it's pretty cool and a real boon for responsive design!
hi Robert
some of what you say is true, but those code changes are due mainly to changes in the version of umbraco.
The code used in a normal mvc view is exactly the same as you would use in your partial, so take your whole view, make the partial from that code and call the partial from the original view and it will work.
I use this to make my partials, write the code in the view, if the code will be repeated elsewhere, then create the partial, cut the code block, paste into the partial and call the partial in the orignal view and wherever else it is needed.
Hope that helps, dive in, give it a try and you can leave macros behind.
regards
gary
It does help... just confused by some of the new things i didn't know about like calling objects with ".AsDyanmic()" and such... Yeah, I am sick of having dozens of macros to do simple things like change headines on the fly, navigation, etc. Gets confusing. Already enjoying the more integrated and structurally solid MVC way...
is working on a reply...