嵌入红宝石“ erb”标签 [英] Embedded ruby "erb" tags
本文介绍了嵌入红宝石“ erb”标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在经历Ruby和Ruby on Rails的速成课程,但我无法弄清楚:
在嵌入式ruby html文件中,有几个标签。
<%%>用于执行
<%=%>用于输出,但是这些标记提供什么功能:<%=-%>,最后带有-符号
I have been going through a crash course of Ruby and Ruby on Rails and i can't figure this out: In embedded ruby html files, there are several tags. <% %> for execution <%= %> for output, but what function do these tags serve: <%= -%>, what's with the "-" sign at the end ?
谢谢。
推荐答案
此链接很好地概述了erb标记。
This link contains a good overview of erb markup.
来自站点:
已识别标签
RECOGNIZED TAGS
ERB识别提供的模板中的某些标签,并根据以下规则将它们转换为
:
ERB recognizes certain tags in the provided template and converts
them based on the rules below:
<% Ruby code -- inline with output %>
<%= Ruby expression -- replace with result %>
<%# comment -- ignored -- useful in testing %>
% a line of Ruby code -- treated as <% line %> (optional -- see ERB.new)
%% replaced with % if first thing on a line and % processing is used
<%% or %%> -- replace with <% or %> respectively
所有其他文本均通过ERB过滤而保持不变。
All other text is passed through ERB filtering unchanged.
这篇关于嵌入红宝石“ erb”标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文