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
I wrote this macro into Razor script cshtml file:
var Node = @Model.NodeById(1059);var Home = Node.AncestorOrSelf();Home.siteversion;@Model.AncestorOrSelf().siteversion;
and insert macro into template, but rendering display me Razor script code and not its result.
Why?
sorry but rendering display -> but display
Is your .cshtml file linked in the macro as a script file? (click the image to enlarge it).
Yes..there is.
Oh right, this is your only code?
In that case you need to put it in a codeblock:
@{ var Node = @Model.NodeById(1059); var Home = Node.AncestorOrSelf(); @Home.siteversion; @Model.AncestorOrSelf().siteversion; }
Which are cases that we should use codeblock?
You use it when you have multiple lines of code, here is a good Razor introduction by Scott Guthrie.
Don't forget to mark an answer as the correct solution so the next one with the same question can find it easily :-)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
v4.7: Razor macro not executed, but display its code
I wrote this macro into Razor script cshtml file:
var Node = @Model.NodeById(1059);
var Home = Node.AncestorOrSelf();
Home.siteversion;
@Model.AncestorOrSelf().siteversion;
and insert macro into template, but rendering display me Razor script code and not its result.
Why?
sorry but rendering display -> but display
Is your .cshtml file linked in the macro as a script file? (click the image to enlarge it).
Yes..there is.
Oh right, this is your only code?
In that case you need to put it in a codeblock:
Which are cases that we should use codeblock?
You use it when you have multiple lines of code, here is a good Razor introduction by Scott Guthrie.
Don't forget to mark an answer as the correct solution so the next one with the same question can find it easily :-)
is working on a reply...