Applying IM Text Abbreviations With ColdFusion

<cffunction
	name="ApplyTextMap"
	access="public"
	returntype="string"
	output="false"
	hint="Applies the given map (name-value structure) to the given text value.">
 
	<!--- Define arguments. --->
	<cfargument
		name="Text"
		type="string"
		required="true"
		hint="The text to which we will be applying the text map."
		/>
 
	<cfargument
		name="Map"
		type="struct"
		required="true"
		hint="The struct containing the key-value text mappings."
		/>
 
	<!--- Define the local scope. --->
	<cfset var LOCAL = StructNew() />
 
	<!--- Set up a local copy of the string. --->
	<cfset LOCAL.Text = ARGUMENTS.Text />
 
 
	<!--- Loop over all values in the struct. --->
	<cfloop
		item="LOCAL.Key"
		collection="#ARGUMENTS.Map#">
 
		<!--- Replace the text with it's mapped value. --->
		<cfset LOCAL.Text = ReplaceNoCase(
			LOCAL.Text,
			LOCAL.Key,
			ARGUMENTS.Map[ LOCAL.Key ],
			"ALL"
			) />
 
	</cfloop>
 
 
	<!--- Return the modified arguments. --->
	<cfreturn LOCAL.Text />
</cffunction>

For Cut-and-Paste