views:

43

answers:

3

Do asp.net aspx views have tags that that work similar to the Ruby erb <% -%> ? I don't like all these line breaks in my asp.net mvc generated html. As for the other view engines (nhaml, spark, razor) I don't want to use them yet.

Quick example of the difference between <% %> and <% -%> in erb:

1. <% %>

<% 3.times do %>
Ho!<br />
<% end %>
Merry Christmas!

gives us:

Ho!<br />

Ho!<br />

Ho!<br />

Merry Christmas!

2. <% -%>

<% 3.times do -%>
Ho!<br />
<% end -%>
Merry Christmas!

gives us:

  Ho!<br />
  Ho!<br />
  Ho!<br />
  Merry Christmas!
A: 

Not sure why you say mimic, as this notation on classic asp and asp.net predates ruby erb.

However, it does exist, and is almost identical. See here (code blocks), expressions and binding expressions.

Oded
A: 

If i'm not misstaken you shoud be able to use <%= expression %> in asp.net to output values

Fredrik Leijon
+1  A: 

<% %> Exists
<% -%> Does not exists

There is small chance that Razor has it. I haven't checked it yet.


To other answerers:

Notice that small minus sign. In rails it means that blank lines will be stripped out.

Arnis L.
That's a pity, I was hoping there is a way to deal with long, full of blank lines HTML in asp.net mvc.
Valentin Vasiliev