Save the following as a tag and place all of your content between the open and end 
tags.

For example, if your tag was called CF_Highlight:

<cfset variables.foo = "This is a sales test">
<cf_highlight text="sales">
        This is a test of the sales system.
        <cfoutput>#variables.foo#</cfoutput>
        End of sales information
</cf_highlight>

Tag Code:

<cfif thistag.ExecutionMode IS "end">
        <cfparam name="attributes.text">
        <cfparam name="attributes.color" default="black">
        <cfparam name="attributes.background" default="yellow">
        
        <cfset variables.markedUpText = "<span 
style='color:#attributes.color#;background:#attributes.background#;'>#attributes.text#</span>">
        <cfset variables.markedUpBody = replace(thistag.GeneratedContent, 
attributes.text, variables.markedUpText, "ALL")>
        <cfoutput>#variables.markedUpBody#</cfoutput>
        <cfset thistag.GeneratedContent = "">
</cfif>

Craig

> -----Original Message-----
> From: Christine Kelley [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, May 09, 2001 4:12 PM
> To:   CF-Talk
> Subject:      Highlighting Text
> 
> Hi!
> 
> How do I go about...
>     Having the Keyword highlighted throughout page.  For 
> example the keyword 'sales' would be shadowed in yellow.
> 
> I've looked into the <CF_Findit> custom tag, but it's not 
> quite what I need.  It would be nice to highlight all the 
> keywords at once.  How about looping through each line and 
> then each word..., but how do I tell it to loop through the 
> entire page (including dynamically filled areas)?
>    This is a tough one :)
>                Thanks,  Christine
> 
> 
> 
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to