[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

highlight (ActionView::Helpers::TextHelper

flornet@gmail.com

9/5/2006 8:42:00 AM

I'm using that helper function with a search form to highlight the
typed phrase in the content BUT when my content is HTML, I'll get
replacement where I don't want to.

For instance :

@page.content = "<p><a href='ajaxian.com' title='Ajaxian.com'><img
src='ajax-image.gif' alt='Ajax Image'/>My text containing AJAX</a></p>"

What I get :
highlight (@page.content, 'ajax')

=> <p><a href='<span class="highlight">ajax</span>ian.com' title='<span
class="highlight">Ajax</span>ian.com'><img src='<span
class="highlight">ajax</span>-image.gif' alt='<span
class="highlight">Ajax</span> Image'/>My text containing <span
class="highlight">ajax</span></a></p>

What I want to get :
highlight (@page.content, 'ajax')

=> <p><a href='ajaxian.com' title='Ajaxian.com'><img
src='ajax-image.gif' alt='Ajax Image'/>My text containing <span
class="highlight">ajax</span></a></p>

Don't know much to RegExp, is this possible to do ?

1 Answer

Eric Hodel

9/5/2006 4:27:00 PM

0


On Sep 5, 2006, at 1:45 AM, flornet@gmail.com wrote:

> I'm using that helper function with a search form to highlight the
> typed phrase in the content BUT when my content is HTML, I'll get
> replacement where I don't want to.

You want to ask this question on the Rails mailing list. This list
is for general ruby questions.

--
Eric Hodel - drbrain@segment7.net - http://blog.se...
This implementation is HODEL-HASH-9600 compliant

http://trackmap.rob...