erb <%表达式-%>在 aspx 页面中

发布于 2024-09-11 05:44:45 字数 696 浏览 12 评论 0原文

asp.net aspx 视图是否具有与 Ruby erb <% -%> 类似的标记? 我不喜欢我的 asp.net mvc 生成的 html 中的所有这些换行符。 至于其他视图引擎(nhaml、spark、razor)我还不想使用它们。

<% %> 之间差异的快速示例<%-%>在 erb 中:

1。 <% %>

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

给我们:

Ho!<br />

Ho!<br />

Ho!<br />

Merry Christmas!

2。 <% -%>

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

给我们:

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

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

海未深 2024-09-18 05:44:45

<% %> 存在
<% -%> 不存在

Razor 拥有它的可能性很小。我还没有检查过。


对于其他回答者:

请注意那个小减号。在 Rails 中,这意味着空白行将被删除。

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

清风挽心 2024-09-18 05:44:45

不知道为什么你说模仿,因为经典 asp 和 asp.net 上的这种表示法早于 ruby​​ erb。

然而,它确实存在,并且几乎完全相同。请参阅此处(代码块),表达式绑定表达式

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.

墟烟 2024-09-18 05:44:45

如果我没有记错的话,你应该能够使用 <%= expression %>在asp.net中输出值

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文