Search code examples
puppeterb

cant figure out how to get this template to render properly


Given the following each block

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

I need it to render like this.

enter image description here

however it is rendering like this

enter image description here

what am i missing?


Solution

  • You need to use space trimming in your non-printing tags. Like this...

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

    The <%- and -%> at the start and end of the first and last lines tells Ruby not to add a line break.