ruby-on-rails – Rails html.erb文件类型,<%%>和&l
发布时间:2020-12-17 03:06:13 所属栏目:百科 来源:网络整理
导读:参见英文答案 What is the difference between %,%=,%# and -% in ERB in Rails?????????????????????????????????????7个 我刚开始深入研究Ruby和Ruby on Rails,我注意到在.html.erb文件中嵌入Ruby语法的两个选项: % #ruby code here % 要么: %= #ruby co
参见英文答案 >
What is the difference between <%,<%=,<%# and -%> in ERB in Rails?????????????????????????????????????7个
我刚开始深入研究Ruby和Ruby on Rails,我注意到在.html.erb文件中嵌入Ruby语法的两个选项: <% #ruby code here %> 要么: <%= #ruby code here %> 我应该如何选择其中一个? 解决方法
<%=输出Ruby的结果. <%just评估Ruby.
<p>Hi! How are you? 1 + 1 = <%= 1 + 1 %></p> 将成为< p>嗨!你好吗? 1 1 = 2< / p>. <p>Hi! How are you? 1 + 1 = <% 1 + 1 %></p> 将成为< p>嗨!你好吗? 1 1 =< / p>. <%通常用于流量控制,例如,如果别的.例: <% if model.nil? %> <%= render 'new_model_form' %> <% else %> <%= render 'detail_view' %> <% end %> 阅读更多http://guides.rubyonrails.org/layouts_and_rendering.html (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |