Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
I am the chief technical officer at InVision App, Inc - a prototyping and collaboration platform for designers, built by designers. I also rock out in JavaScript and ColdFusion 24x7.
Meanwhile on Twitter
Loading latest tweet...
Ben Nadel at Scotch On The Rocks (SOTR) 2011 (Edinburgh) with: Aurélien Deleusière

ColdFusion Cheat Sheet: Ripping HomeSite's Help Directories

By Ben Nadel on
Tags: ColdFusion

I am making a real push right now to learn more about the ColdFusion language as a whole. I know there are a lot of functions that exist that I either don't know about and/or don't use. That's about to change. In an effort to learn ColdFusion, I have made my own ColdFusion cheat sheet. Now, I saw "my own", but really, it's just a stripped down version of my HomeSite 5.5 help files:

ColdFusion Function Cheat Sheet

The HomeSite help docs have a lot of stuff that I am not interested in such as the Examples, History, and Usage. I am stripping those out. Further more, I am putting it all on one page (about 100+ printable pages) so that I can easily scroll through and search for stuff. Again, nothing here is new, only that I find it more accessible.

Perhaps the most interesting aspect about it is the way it was created. HomeSite stores the function help files as individual files. I read each one in, strip it down, and then output it:

  • <!---
  • Read in the directory files from the Functions help
  • file (copied over from HomeSite program files).
  • --->
  • <cfdirectory
  • action="LIST"
  • name="qFunctions"
  • directory="#ExpandPath( './CFMLFunctions/' )#"
  • sort="NAME ASC"
  • />
  •  
  •  
  • <!--- Loop over every file in the help directory. --->
  • <cfloop query="qFunctions">
  •  
  • <!--- Read in the file. --->
  • <cffile
  • action="READ"
  • variable="strFileData"
  • file="#ExpandPath( './CFMLFunctions/#qFunctions.name#' )#"
  • />
  •  
  • <!--- Get rid of body. --->
  • <cfset strFileData = strFileData.ReplaceFirst(
  • "^[\w\W]+?<body[^>]*>",
  • ""
  • ) />
  •  
  • <!--- Get rid of post-body. --->
  • <cfset strFileData = strFileData.ReplaceFirst(
  • "</body[^>*]>[\w\W]*",
  • ""
  • ) />
  •  
  • <!--- Get rid of post usage. --->
  • <cfset strFileData = strFileData.ReplaceFirst(
  • "<h(3|4)[^>]*>((?!Usage).)*Usage[\w\W]*",
  • ""
  • ) />
  •  
  • <!--- Get rid of example. --->
  • <cfset strFileData = strFileData.ReplaceFirst(
  • "<h(3|4)[^>]*>((?!Example).)*Example[\w\W]*",
  • ""
  • ) />
  •  
  • <!--- Get rid of history. --->
  • <cfset strFileData = strFileData.ReplaceFirst(
  • "<h(3|4)[^>]*>((?!History).)*History[\w\W]*?(<h(3|4))",
  • "$3"
  • ) />
  •  
  • <!--- Get rid of category. --->
  • <cfset strFileData = strFileData.ReplaceFirst(
  • "<h(3|4)[^>]*>((?!Category).)*Category[\w\W]*?(<h(3|4))",
  • "$3"
  • ) />
  •  
  • <!--- Get rid of 'see also'. --->
  • <cfset strFileData = strFileData.ReplaceFirst(
  • "<h(3|4)[^>]*>((?!See).)*See[\w\W]*?(<h(3|4))",
  • "$3"
  • ) />
  •  
  • <!--- Fix table. --->
  • <cfset strFileData = strFileData.ReplaceAll(
  • "<table",
  • "<table border=""1"""
  • ) />
  •  
  • <!--- Output file data (Remember: it is a Java string). --->
  • #strFileData.ToString()#
  •  
  • </cfloop>

This is a smaller version of what I did, but the end result is a rather nice version of the ColdFusion Function definitions. The help docs themselves were not totally consistent, so not all of the headers come out looking perfect, but it's pretty darn close.

One cool thing about what I am doing above is that I am reading the file data in as a string but then I am using the underlying Java String::ReplaceAll() and Java String::ReplaceFirst() methods. Sweeeet.

I will be doing the CFML tags in the same way and those will be accessible at http://www.bennadel.com/cfml/.



Reader Comments

Maybe consider using frames. THe left frame would just be an alpha list of the funcs/tags.

Of course, it is nice having it as one simple page. Right now I use cfQuickDocs for all my doc needs, but I may download yours for times when I'm offline.

Reply to this Comment

Yeah, the frames thing would be nice for presentation, but exactly as your are saying, its nice to have them all in one page to just scroll through. The problem is, there is too much info and printing it out to read on the train (as I did), is akin to just having a CFMX reference book. I guess the difference is that the help docs are *free* and you would have to buy a book. But I think its gonna be nice to be able to just hit up bennadel.com/cfml/ to get a quick guide.

Reply to this Comment

Post A Comment

You — Get Out Of My Dreams, Get Into My Comments
Live in the Now
Oops!
Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.