Skip to content

Instantly share code, notes, and snippets.

@anandkunal
Created March 8, 2010 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anandkunal/324963 to your computer and use it in GitHub Desktop.
Save anandkunal/324963 to your computer and use it in GitHub Desktop.
ColdFusion Tagging Library
<cfset tags_list = " CaMELCaSE comma, 'singlequoted' <b>bold</b> ""doublequoted"" double double this should be over the limit now " />
<cfset amount = 10 />
<cfset length = 20 />
<pre><cfset tags_list = trim(tags_list) />
<cfset tags_list = lcase(tags_list) />
<cfset tags_struct = structnew() />
<cfloop index="tag" list="#tags_list#" delimiters=" ">
<cfset tags_struct[tag] = "" />
</cfloop>
<cfset tags_list = structkeylist(tags_struct," ") />
<cfset tags_list = listsort(tags_list, "textnocase", "asc", " ") />
<cfif tags_list neq "">
<cfif listlen(tags_list," ") lte amount>
<cfset amount = listlen(tags_list," ") />
</cfif>
<cfloop from="1" to="#amount#" index="tag">
*** Perform a database insert/update here ***
<cfoutput>#htmleditformat(left(listgetat(tags_list,tag," "),length))#</cfoutput>
</cfloop>
<cfelse>
Sorry, you need to provide at least one tag
</cfif>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment