Having great difficulty with Razor syntax here. It's an Umb 6.0.2 site.
var heading = sectionLeft.IsFirst("h1","h2");
<@heading>@sectionLeft.sectionTitle</@heading>
Puts out <h1>Some text</@(heading)> instead of <h1>Some text</h1> and I can't work out why after Googling and "ouring" for ages. I have the Razor cheat sheet but it's not helping me on syntax. Finding Razor hard going to be honest. Particularly when mixing HTML with code.
<heading>sectionLeft.sectionTitle</heading> } be easier?
For the var to be recognised (blue) you are in a codeblock, so do not need the @: which takes you out of codeblock, then another @heading to put you back in, kinda like a double negative?
You can get intellisense on these in both VS and WebMatrix, so this can help sort out snippets like this.
The syntax is a nightmare. You can't tell where you are (in code or out) at any one point and it's not at all obvious. I'm using VS2012 update 1 which has a bug to be fixed for update 2 which is no Razor intellisense, so I read yesterday.
<heading>sectionLeft.sectionTitle</heading> just looks so wrong and dangerous to me. <heading></heading> could be a perfectly valide html5 tag set so it should switch back to html at that point as far as I understood. Maybe I'll get used to it with experience.
Razor as time consuming as XSLT
Hi,
Having great difficulty with Razor syntax here. It's an Umb 6.0.2 site.
Puts out <h1>Some text</@(heading)> instead of <h1>Some text</h1> and I can't work out why after Googling and "ouring" for ages. I have the Razor cheat sheet but it's not helping me on syntax. Finding Razor hard going to be honest. Particularly when mixing HTML with code.
Any pointers would be appreciated.
Craig
And for those, like me that were wondering, the answer is:-
;)
Craig
Hi Craig
You have me intrigued
Given what you have above would;
@{ var heading = sectionLeft.IsFirst("h1","h2");
<heading>sectionLeft.sectionTitle</heading> } be easier?
For the var to be recognised (blue) you are in a codeblock, so do not need the @: which takes you out of codeblock, then another @heading to put you back in, kinda like a double negative?
You can get intellisense on these in both VS and WebMatrix, so this can help sort out snippets like this.
G
Hi Gary,
The syntax is a nightmare. You can't tell where you are (in code or out) at any one point and it's not at all obvious. I'm using VS2012 update 1 which has a bug to be fixed for update 2 which is no Razor intellisense, so I read yesterday.
<heading>sectionLeft.sectionTitle</heading> just looks so wrong and dangerous to me. <heading></heading> could be a perfectly valide html5 tag set so it should switch back to html at that point as far as I understood. Maybe I'll get used to it with experience.
Craig
is working on a reply...