3 ms·
While I'm certainly glad that Phil & co are finally replacing the inadequate WebForms view engine with something better, I'm nonplussed that the "something bett
by troygoode 16y ago
While I'm certainly glad that Phil & co are finally replacing the inadequate WebForms view engine with something better, I'm nonplussed that the "something better" still isn't at least as good as Spark - especially since Louis (the creator of Spark) works on the Asp.net team now.
I realize that Spark's fake-HTML-element syntax would not be everyone's personal favorite (reminders of: Cold Fusion, WebForm server controls), the fact is that Spark provides a good bit of "value add" on top of the normal view engine goodness.
Example (in Spark):
<ul>
<li each="var p in Model.Products"
class="alt?{pIndex%2!=0} isFirst?{pIsFirst} isLast?{pIsLast}">
Product: ${p.Name}
</li>
</ul>
Would output:
<ul>
<li class="isFirst">Product: AAA</li>
<li class="alt">Product: BBB</li>
<li>Product: CCC</li>
<li class="alt isLast">Product: DDD</li>
</ul>
The alternation of rows and detection of first/last row is an _extremely_ common scenario for web developers that Spark totally gets right, but so far Razor just ignores. I'm glad there will be an option for the masses that are just using whatever is packed in the box, but so far I'm not seeing what all the fuss is for those of us that long since moved on from the built-in ViewEngine.
- rbanffy 16y agoInteresting. It reminds me of Zope's Page Templates. I find Spark's syntax to be dirtier, however. Has anyone implemented ZPT for .NET?
- troygoode 16y agoI don't know of any .NET implementation of ZPT. What makes you find Spark's syntax to be dirtier than ZPT? Is it the fact that the Spark example I gave isn't valid XHTML like ZPT is? If so, that is simply out of convenience - Spark also offers a way to use proper XML namespacing to achieve complete XHTML compliance: http://www.sparkviewengine.com/documentation/syntax http://www.sparkviewengine.com/documentation/syntax (scroll all the way down)
- rbanffy 16y agoCool. And yes - the shortcuts are something I frown upon. Template languages should not be so expressive as to create an incentive to ASP-style coding, nor too castrated as to prevent you from doing whatever you want. I think ZPT is right in the middle of the sweet spot.