Hello ! I''m new to this list and new to RoR too, but not to Ruby ;-) I''m wondering how I can escape (html entities) for a given variable in a string. For example : :confirm => "Are you sure you want to delete #{category.category}?" I want to escape #{category.category}. I know that I can use <%=h %> but I only want to escape the #{} part of the string or it would break the HTML page. Thank you in advance for your help. Have a good night ! -- Nicolas Cavigneaux | GPG KeyID : CFE76D24 nico-DRabjd/C3MEdnm+yROfE0A@public.gmane.org | http://www.bounga.org _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 5/9/05, Nicolas Cavigneaux <nico-DRabjd/C3MEdnm+yROfE0A@public.gmane.org> wrote:> Hello ! > > I''m new to this list and new to RoR too, but not to Ruby ;-) > > I''m wondering how I can escape (html entities) for a given variable in a > string. For example : > :confirm => "Are you sure you want to delete #{category.category}?" > > I want to escape #{category.category}. I know that I can use <%=h %> but > I only want to escape the #{} part of the string or it would break the > HTML page.Then use: :confirm => "Are you sure you want to delete #{h(category.category)}?" h is just an alias for escapehtml.> Thank you in advance for your help. > > Have a good night ! > -- > Nicolas Cavigneaux | GPG KeyID : CFE76D24 > nico-DRabjd/C3MEdnm+yROfE0A@public.gmane.org | http://www.bounga.org > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-- Cheers Koz
On 09/05/2005, Michael Koziarski wrote :> > I want to escape #{category.category}. I know that I can use <%=h %> but > > I only want to escape the #{} part of the string or it would break the > > HTML page. > > Then use: > > :confirm => "Are you sure you want to delete #{h(category.category)}?" > > h is just an alias for escapehtml.Oh ! I was not aware of that ! Thank you. -- Nicolas Cavigneaux | GPG KeyID : CFE76D24 nico-DRabjd/C3MEdnm+yROfE0A@public.gmane.org | http://www.bounga.org _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails