I''m creating a generator that needs to put the following code in: <%= link_to "text", :controller => [CHANGE ME], :action => [CHANGE ME] %> However, the <% and %> tags are trying to be run as ruby code immediately. How can I escape the erb evaluation and actually insert the characters <%= ? Thanks, Duane Johnson (canadaduane)
On May 24, 2005, at 1:10 PM, Duane Johnson wrote:> I''m creating a generator that needs to put the following code in: > > <%= link_to "text", :controller => [CHANGE ME], :action => [CHANGE > ME] %> ><%%= link_to "text", :controller => [CHANGE ME], :action => [CHANGE ME] %> Note the double ''%'' in the beginning, but the single ''%'' at the end.> However, the <% and %> tags are trying to be run as ruby code > immediately. How can I escape the erb evaluation and actually > insert the characters <%= ? > > Thanks, > Duane Johnson > (canadaduane) > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >Joseph Hosteny jhosteny-ee4meeAH724@public.gmane.org H: 412.362.8672 C: 412.418.6023
Hello, Just change the first <%= to <%%= and it will be changed back to <%= in your generated file. 2005/5/24, Duane Johnson <duane.johnson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > I''m creating a generator that needs to put the following code in: > > <%= link_to "text", :controller => [CHANGE ME], :action => [CHANGE > ME] %> > > However, the <% and %> tags are trying to be run as ruby code > immediately. How can I escape the erb evaluation and actually insert > the characters <%= ? > > Thanks, > Duane Johnson > (canadaduane) > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Rafael Rezende _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
In case this is useful to others, a solution has been found: <%= _erbout.concat("<" + "%=") %> link_to <%= image.css_tag.humanize % > <%= _erbout.concat("%" + ">") %> Is this the only way to do it? (Ugly!) Duane Johnson (canadaduane) On May 24, 2005, at 11:10 AM, Duane Johnson wrote:> I''m creating a generator that needs to put the following code in: > > <%= link_to "text", :controller => [CHANGE ME], :action => [CHANGE > ME] %> > > However, the <% and %> tags are trying to be run as ruby code > immediately. How can I escape the erb evaluation and actually > insert the characters <%= ? > > Thanks, > Duane Johnson > (canadaduane) >
> In case this is useful to others, a solution has been found: > > <%= _erbout.concat("<" + "%=") %> link_to <%= > image.css_tag.humanize %> <%= _erbout.concat("%" + ">") %>Sorry to post again, but that last post didn''t quite do what I thought it did. Here''s a solution that is less ugly (and it works this time :) <%= "<" + "%=" %> link_to <%= image.css_tag.humanize %> <%= "%" + ">" %> %> Duane Johnson (canadaduane)