Search code examples
asp.netasp.net-mvcrubyerbviewengine

erb <% expression -%> in aspx pages


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!

Solution

  • <% %> 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.