如何在erb模板中发表评论? [英] How does one comment in an erb template?

查看:55
本文介绍了如何在erb模板中发表评论?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些琐碎的标记,如下所示:

I have some trivial markup that looks like the following:

<li class="someclass">
  <=% t'model.attr' %>
</li>

有没有简单的方法可以对此进行评论?仅将<!--> 包裹在该块周围,仍将红宝石代码保留给模板使用。这意味着我必须分别注释掉HTML和Ruby特定的代码。

Is there a trivial way to comment that out? Just wrapping <!-- --> around the block will still leave the ruby code available to the template. This means I have to comment out the HTML and Ruby specific code separately.

用最少的标记注释掉所有三行的最佳方法是什么?

What's the best way to comment out all three lines with the least amount of markup?

推荐答案

=开始 = end 是块注释的Ruby版本。

=begin and =end are the Ruby version of block comments.

在erb模板中使用它们:

Using them in an erb template:

<%
=begin
%>
<li class="someclass">
  <=% t'model.attr' %>
</li>
<%
=end
%>

这篇关于如何在erb模板中发表评论?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆