# Render :partial inserting new line in RJS

**URL:** <https://www.ruby-forum.com/t/render-partial-inserting-new-line-in-rjs/98994>\
**Category:** Rails\
**Created:** [July 19, 2006, 5:17pm UTC](https://www.ruby-forum.com/t/render-partial-inserting-new-line-in-rjs/98994 "2006-07-19T17:17:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@Chris\_T](https://www.ruby-forum.com/u/Chris_T)\
**Post date:** [July 19, 2006, 5:17pm UTC](https://www.ruby-forum.com/t/render-partial-inserting-new-line-in-rjs/98994/1 "2006-07-19T17:17:41Z")

</div>

Struggling a bit with rendering a partial in an RJS template. I’m having  
to feed the javascript directly to the page object as couldn’t find a  
way to have insert\_html work directly on the proxy object returned by  
select.

However, that’s not the problem. The code for doing that is below and it  
all works fine, except that a new line is being inserted after the  
partial and before the final single quote, which means the string isn’t  
terminated. It’s definitely not in the partial, which is a simple  
one-line:

- \<%= #stuff %\>

page \<\< “first\_item = $$(’#rant\_list li’).first(); new Insertion.Before  
first\_item, ‘#{render(:partial =\> ‘rant\_list\_item’, :object =\>  
@rant)}’;”

Anybody got any ideas why it’s doing this?

---

<div class="post-metadata">

**Author:** ![Chris\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@Chris\_T](https://www.ruby-forum.com/u/Chris_T)\
**Post date:** [July 19, 2006, 7:30pm UTC](https://www.ruby-forum.com/t/render-partial-inserting-new-line-in-rjs/98994/2 "2006-07-19T19:30:55Z")

</div>

Oddly, this works fine if I cut and paste the partial and do a render  
:inline with the cut and pasted code

---

<div class="post-metadata">

**Author:** ![Chris\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@Chris\_T](https://www.ruby-forum.com/u/Chris_T)\
**Post date:** [July 20, 2006, 3:38pm UTC](https://www.ruby-forum.com/t/render-partial-inserting-new-line-in-rjs/98994/3 "2006-07-20T15:38:13Z")

</div>

OK. Refactored the problem out by arranging my divs differently. Still,  
puzzling…

---

<div class="post-metadata">

**Author:** ![Chris\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@Chris\_T](https://www.ruby-forum.com/u/Chris_T)\
**Post date:** [July 20, 2006, 9:14am UTC](https://www.ruby-forum.com/t/render-partial-inserting-new-line-in-rjs/98994/4 "2006-07-20T09:14:16Z")

</div>

Anyone?
