# ActionMailer view template:

**URL:** <https://www.ruby-forum.com/t/actionmailer-view-template/166914>\
**Category:** Rails\
**Created:** [April 30, 2009, 8:49pm UTC](https://www.ruby-forum.com/t/actionmailer-view-template/166914 "2009-04-30T20:49:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 30, 2009, 8:49pm UTC](https://www.ruby-forum.com/t/actionmailer-view-template/166914/1 "2009-04-30T20:49:21Z")

</div>

I am attempting to generate a plain text list from an array of arrays.

If I do this:

\<% for currency in @rates -%\>  
\<% if currency[2] == ‘USD’ -%\>  
\<%= currency[2] -%\> … \<%= currency[4] %\>  
\<% end -%\>  
\<% end -%\>

Then I see this:

```
                                                                     =
                              USD ............... 1.203804
          =

```

If I do this:

\<% for currency in @rates -%\>  
\<%= currency[2] -%\> … \<%= currency[4] %\>  
\<% end -%\>

Then I see this:

```
 AED ............... 0.327697
 ANG ............... 0.6879
 ARS ............... 0.324296
 AUD ............... 0.869868

```

How is the if statement causing the difference?

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 30, 2009, 9:13pm UTC](https://www.ruby-forum.com/t/actionmailer-view-template/166914/2 "2009-04-30T21:13:38Z")

</div>

James B. wrote:

The problem occurs even if the output line is a literal:

\<% if true -%\>  
\<%= “print this” %\>  
\<% end -%\>

\<% for currency in @rates -%\>  
\<% if currency[2] == ‘USD’ -%\>  
\<%= “print this” %\>  
\<% end -%\>  
\<% end -%\>

gives this:

print this

```
                                                                     =
                             print this
          =
```

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 30, 2009, 10:47pm UTC](https://www.ruby-forum.com/t/actionmailer-view-template/166914/3 "2009-04-30T22:47:26Z")

</div>

You are still getting all the indentation from the iterations that are  
skipped (i.e., where the currency is not USD).

\<% for currency in @rates -%\>  
\<% next unless currency[2] == ‘USD’ -%\>  
\<%= currency[2] %\> … \<%= currency[4] %\>  
\<% end -%\>

I’m not sure you need the minus sign on an emitting tag (\<%=) to  
suppress the linefeed.

Does this help?

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 30, 2009, 10:54pm UTC](https://www.ruby-forum.com/t/actionmailer-view-template/166914/4 "2009-04-30T22:54:05Z")

</div>

Steve R. wrote:

> You are still getting all the indentation from the iterations that are  
> skipped (i.e., where the currency is not USD).
> 
> \<% for currency in @rates -%\>  
> \<% next unless currency[2] == ‘USD’ -%\>  
> \<%= currency[2] %\> … \<%= currency[4] %\>  
> \<% end -%\>
> 
> I’m not sure you need the minus sign on an emitting tag (\<%=) to  
> suppress the linefeed.
> 
> Does this help?

Yes. Now that I know what is going on this works as I wish:

\<% for currency in @rates  
usdd = “#{currency[2]} … #{currency[4]}” if  
currency[2] == ‘USD’  
end -%\>

```
  <%=usdd%>
```
