Hi All, I need a way to place floated images into the body of an article. The body is pulled from the database, so I need a way to scan a certain number of words, or paragraphs, and then place an image_tag in there. Thanks in advance for any help. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
I''d recommend you look to another list (css-d for example) for help like this. hth, Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
This isn''t a css question. What I need to know is how to split up a large amount of text into paragraphs, based on newlines (as entered in a textarea) or the occurrence of a closing paragraph tag and an open one, and insert imagetags in between them. Ideally, what I need is the equivalent of php''s substr_replace function. This is probably a rudimentary question, but it''s definitely not a css question. On 9/8/06, Bill Walton <bill.walton-xwVYE8SWAR3R7s880joybQ@public.gmane.org> wrote:> > I''d recommend you look to another list (css-d for example) for help like > this. > > hth, > Bill > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
> This isn''t a css question. What I need to know is how to split up a > large amount of text into paragraphs, based on newlines (as entered in > a textarea) or the occurrence of a closing paragraph tag and an open > one, and insert imagetags in between them. Ideally, what I need is > the equivalent of php''s substr_replace function.The equivalent function you''re after is ruby''s String gsub function which will replace stuff based on a regular expression: content = content.gsub(/\<\/p\>\<p\>/, "<p>" << image_tag("myimage.jpg") << "</p>") This is obviously a *very* contrived and buggy example, but it should demonstrate the concept. You can also modify a string in place using string.gsub!() If you haven''t already, I''d recommend you get the pragmatic programmers'' ''Programming Ruby'' book (otherwise known as the ''pickaxe''). It''ll really take you further into ruby itself and help you easily solve problems like this. Hope that helps, Steve --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
That''s great (both your solution and suggestion). Thanks On 9/9/06, Stephen Bartholomew <steve-lcUDh2uYFES1Qrn1Bg8BZw@public.gmane.org> wrote:> > > This isn''t a css question. What I need to know is how to split up a > > large amount of text into paragraphs, based on newlines (as entered in > > a textarea) or the occurrence of a closing paragraph tag and an open > > one, and insert imagetags in between them. Ideally, what I need is > > the equivalent of php''s substr_replace function. > > The equivalent function you''re after is ruby''s String gsub function > which will replace stuff based on a regular expression: > > content = content.gsub(/\<\/p\>\<p\>/, "<p>" << image_tag("myimage.jpg") > << "</p>") > > This is obviously a *very* contrived and buggy example, but it should > demonstrate the concept. You can also modify a string in place using > string.gsub!() > > If you haven''t already, I''d recommend you get the pragmatic programmers'' > ''Programming Ruby'' book (otherwise known as the ''pickaxe''). It''ll > really take you further into ruby itself and help you easily solve > problems like this. > > Hope that helps, > > Steve > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---