Maksim Kondratyuk
Maksim Kondratyuk

Reputation: 1399

ASP.NET MVC Spark view engine

What pros(positive sides) of using Spark view engine for ASP.NET MVC project. Why it better then default view engine?

Upvotes: 13

Views: 2927

Answers (3)

sianabanana
sianabanana

Reputation: 920

I really like the Bindings features.

http://sparkviewengine.com/documentation/bindings

You can specify something in the bindings and use nice xml markup for it in your views.

We have bindings for all the html helpers we use in our views eg. <textbox for=""/> <dropdown for="" items=""/> etc etc...

Upvotes: 0

user434917
user434917

Reputation:

One important thing about Spark View engine is that its syntax is very similar to HTML syntax, that way your views will be clean and you will avoid "tag soup" that is in WebForms View engine. here is an example:

Spark:

<viewdata products="IEnumerable[[Product]]"/>
<ul if="products.Any()">
  <li each="var p in products">${p.Name}</li>
</ul>
<else>
  <p>No products available</p>
</else>

WebForms:

<%var products = (IEnumerable<Product>)ViewData["products"] %>
<% if (products.Any()) %>
<ul>
<% foreach (var p in products) { %>
<li><%=p.Name %></li>
</ul>
<%} }  %>
<% else { %>
      <p>No products available</p>
<% }%>

Upvotes: 24

Razzie
Razzie

Reputation: 31232

It avoids the HTML tag soup you see a lot. Consider Spark:

<ul>
  <li each='var p in ViewData.Model.Products'>
    ${p.Name}
  </li>  
</ul>

as opposed to the classic html tag soup variant:

<ul>
  <% foreach(var p in ViewData.Model.Products) { %>
  <li>
    <%= p.Name %>
  </li>
  <% } %>
</ul>

The Spark syntax is much cleaner.

Upvotes: 8

Related Questions