Forum: Ruby on Rails input '>' character into html builder array

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
David (Guest)
on 2009-01-14 05:51
(Received via mailing list)
I'm using an html calendar builder and am getting a compile error when
trying to input a close to some ruby code into the cell_input:
cell_text << "%>", it seems that it is choking on the closing > sign.
Is there any way to escape this?

I could really use some help here, not sure how to search for
information on this.  Thanks.
This is the line that I am having issues with:

  cell_text << "%>"

This is the error output:

ActionView::TemplateError (compile error
syntax error, unexpected $undefined, expecting kEND
...<< ").to_s); _erbout.concat "\"\n  \n  \n\n\n    [cell_text,...
                              ^
 syntax error, unexpected $end, expecting ')') on line #37 of users/
_calendar_large_data.rhtml:
34:
35:   cell_text << "<%= "
36:   cell_text << "javascript_tag \"new Popup('test_popup_#{@day}',
'test_popup_link_#{@day}',{position:'25%,30%', trigger:'click',
modal:true})\""
37:   cell_text << "%>"
38:
39:
40:

I was having a similar compile issue with inputting double quotes into
the cell_text array and was able to use \ to avoid any problems:

cell_text << "<div id=\"test_popup_#{@day}\" class=\"cal_popup\" style=
\"display:none\">"
Frederick C. (Guest)
on 2009-01-14 15:49
(Received via mailing list)
On 14 Jan 2009, at 03:50, David wrote:

>  cell_text << "%>"
>

<% and %> are special in erb. You need to use <%% and %%> to include
literal <% and %>
Or avoid the whole lot by putting it in a helper.

Fred
This topic is locked and can not be replied to.