Hi,
ERB documentation for Ruby 1.8.7 and Ruby 1.9.3 shows the following
modifiers for trim_mode:
% enables Ruby code processing for lines beginning with %
<> omit newline for lines starting with <% and ending in %>
omit newline for lines ending in %>
However, I’ve seen in several discussions the ‘-’ modifier. Looking at
ERB source, it seems it has different behavior for ‘>’ and ‘-’. What is
the difference and what does the ‘-’ modifier do?
Is a trim_mode of ‘%<>>’ valid or ‘<>’ and ‘>’ are mutually exclusive?
If I understood correctly, the following listing from ERB source
indicates that ‘<>’, ‘>’, and ‘-’ are mutually exclusive, and valid
trim_modes are the combination of the ‘%’ with just one of the other
modifiers.
def prepare_trim_mode(mode)
case mode
when 1
return [false, ‘>’]
when 2
return [false, ‘<>’]
when 0
return [false, nil]
when String
perc = mode.include?(’%’)
if mode.include?(’-’)
return [perc, ‘-’]
elsif mode.include?(’<>’)
return [perc, ‘<>’]
elsif mode.include?(’>’)
return [perc, ‘>’]
else
[perc, nil]
end
else
return [false, nil]
end
end
Thanks,