I've put together a fairly simple razor script where I'm building up a string and attempting to output the result to the page but I'm getting an error that I'm missing a } and for the life of me I can't see what's wrong. Could anyone assist please?
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
var folderNode = Umbraco.TypedContent(1068);
var playList = "";
var counter = 0;
foreach(var node in folderNode.Children)
{
playList = "'" + @node.Name + "':[";
foreach(var song in node.Children)
{
playList = playList + counter.ToString() + ",";
counter++;
}
playList += "],";
}
@Html.Raw(playList);
}
Razor Syntax Error
Hi all,
I've put together a fairly simple razor script where I'm building up a string and attempting to output the result to the page but I'm getting an error that I'm missing a } and for the life of me I can't see what's wrong. Could anyone assist please?
Thanks, C
Hi Craig,
I think the error about a missing } is possibly a bit misleading.
The first thing that jumped out to me was this line here:
I'm pretty sure you don't need the
@
beforenode.Name
Try removing that and see if it decides to behave for you.
Cheers
Nik
Hi Craig,
Nik is correct.. below are your updated code.
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
}
@Html.Raw(playList);
}
Awesome! Couldn't see the wood for the trees there.
Thanks folks!
is working on a reply...