Built-in ruby ​​"erb" tags

I went through the crash course of Ruby and Ruby on Rails, and I can’t understand this: There are several tags in the ruby ​​html embedded files. <%%> to execute <% =%> for output, but what function do these tags perform: <% = -%>, what is the β€œ-" sign at the end?

Thank.

+5
source share
2 answers

This link provides a good overview of erb markup.

From the website:

RECOGNITIVE TAGS

ERB recognizes specific 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

All other texts are transmitted through ERB filtering without changes.

+2
source

<%- -%>. :

erbA = ERB.new(erbA_str, 1, '-', "@output_buffer")

'-' ! <%- -%> .

+1

All Articles