无法弄清楚如何让这个模板正确呈现

cant figure out how to get this template to render properly

给定以下每个块

<%@variables.each do | index, value |%>
<%= 'export ' + index.upcase %>=<%= value.upcase%>
<%= 'export ' + index.downcase %>=<%= value.downcase%>
<%end%>

我需要它像这样渲染。

然而它是这样呈现的

我错过了什么?

您需要在 non-printing tags 中使用 space 修剪。像这样...

<%- @variables.each do | index, value | -%>
<%= 'export ' + index.upcase %>=<%= value.upcase %>
<%= 'export ' + index.downcase %>=<%= value.downcase %>
<%- end -%>

第一行和最后一行开头和结尾的<%--%>告诉Ruby不要添加换行符。