<p>I have a rails template (.rhtml file) generating a Javascript object. It looks something like the following:</p>

<pre><code>var volumes = {
  &lt;% for volume in @volumes %&gt;
    &lt;%= volume.id %&gt; : &lt;%= volume.data %&gt; 
    &lt;%= ',' unless volume === @volumes.last %&gt;
  &lt;% end %&gt;
};
</code></pre>

<p>Note the <code>unless</code> statement modifier to suppress printing the comma after the last element (to satisfy Internet Explorer, which incredibly doesn't support trailing commas in JSON properties declarations).</p>

<p>This appears to work, but as a matter of style, do people think it is reasonable to rely on <code>&lt;%= value unless condition %&gt;</code> in the template generating an appropriate <code>render</code> call?</p>

I don't see why not, but generally if you find yourself conditionalizing a comma on the last member, you probably want to use
```
join
```
instead:
```
```
<%= @volumes.map {|v| "#{v.id} : #{v.data}"}.join "," %>
```
```