erb <%表达式-%>在 aspx 页面中
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
<% %>
存在<% -%>
不存在Razor 拥有它的可能性很小。我还没有检查过。
对于其他回答者:
请注意那个小减号。在 Rails 中,这意味着空白行将被删除。
<% %>
Exists<% -%>
Does not existsThere 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.
不知道为什么你说模仿,因为经典 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.
如果我没有记错的话,你应该能够使用 <%= expression %>在asp.net中输出值
If i'm not misstaken you shoud be able to use <%= expression %> in asp.net to output values