Is the following code fragment easier than it's XSLT counterpart?
<ul>
@foreach (var aChild in Item.Children.Where(Child => Child["ShowInMenu"] != "0"))
{
<li>@aChild.Name</li>
}
</ul>
That is a simple sample, but what about "Creating a tree like left menu"? In XSLT Brian Pedersen does it like this, a very good sample. What would that look like in Razor? A simple sample, without reuse/recursion:
<ul>
@foreach (var aChild in Item.Children.Where(Child => Child["ShowInMenu"] != "0"))
{
<li>@aChild.Name
<ul>
@foreach (var bChild in aChild.Children.Where(Child => Child["ShowInMenu"] != "0"))
{
<li>@bChild.Name</li>
}
</ul>
</li>
}
</ul>
Is this something people would like in favor of XSLT's? The guys at Sitecore could add some helpers, modelbinders and stuff like that to make MVC even easier (They might be working on it right now), is a LINQ query easier to understand that XPATH?
Would this make Sitecore development even more productive?
I think so, do you?
Why don't you give it a try? I created a module that allows for Razor templates to be integrated into Sitecore. I'd really like to hear your opinion! Check out the following url: http://dotnetminute.blogspot.com/2011/06/razorforsitecore-module-enable-razor.html
ReplyDelete