嵌入式ruby"erb"标签

Xep*_*ris 5 ruby tags erb

我一直在经历Ruby和Ruby on Rails的速成课程,我无法弄清楚:在嵌入式ruby html文件中,有几个标签.执行<%=%>的输出<%%>,但这些标签的功能是什么:<%= - %>,最后带有" - "符号的是什么?

谢谢.

kso*_*sol 2

此链接包含 erb 标记的详细概述。

从网站:

识别标签

ERB 识别提供的模板中的某些标签并
根据以下规则对其进行转换:

<% 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
Run Code Online (Sandbox Code Playgroud)

所有其他文本均不变地通过 ERB 过滤。

  • 链接已死。存档版本:http://wayback.archive.org/web/20100215150502/http://cheat.errtheblog.com/s/erb/ (3认同)