Viewing By Entry / Main
December 8, 2005

If you're a blog CFC user, you're probably aware that you can easily include code snippets in your posts by surrounding the code with <code>...</code>. What you may not be aware of is how auto-formatting is handled within the code blocks. Take the following two examples:

Example 1:

<cfif arraylen(results.len) is 0>
<cfset arrayappend(results.len, 0)>
<cfset arrayappend(results.pos, 0)>
</cfif>

Example 2:

<cfif arraylen(results.len) is 0>
   <cfset arrayappend(results.len, 0)>
   <cfset arrayappend(results.pos, 0)>
</cfif>

At first glance, you're probably thinking "what's the big deal? The first example has no indenting and the second one does". You would be partially right. What isn't obvious at first glance, though, is that both code example I posted DO have indenting. The difference is the first example indents using spaces while the second one uses tabs. The color coding method used by blogCFC will only auto-indent code that's been indented using tabs.

I know people debate the tabs vs. spaces issue all the time. Bottom line here, though, is that if you want to have your code intented in blogCFC, you'll need to make sure your IDE uses tabs and not spaces for indents.

Comments
Sean Corfield's Gravatar Well, you can't use TAB when entering the code by hand in a web form!
# Posted By Sean Corfield | 12/8/05 8:46 PM
Rob Brooks-Bilson's Gravatar Sean,

Very true. Although, I tend to enter most of my code by cutting and pasting from my IDE. The code coloring method could be modified to indent for tabs as well as leading spaces. Any takers?
# Posted By Rob Brooks-Bilson | 12/8/05 9:03 PM
nick tong's Gravatar Also if you use a WYSIWYG editor it has major issues...

view http://www.succor.co.uk/index.cfm/2005/12/2/cf-cod...
# Posted By nick tong | 12/9/05 6:15 AM
Christopher Jordan's Gravatar Rob,

I know this post is *way* old, but it just answered my exact question. I couldn't find in the documentation where this little tid-bit was explained, nor anywhere on the BlogCFC forums. Just a few minutes trying to get the google search string right brought me to this post.

Thanks mate!
# Posted By Christopher Jordan | 5/16/07 1:57 PM
Rob Brooks-Bilson's Gravatar Thanks Christopher, I'm glad it was helpful.
# Posted By Rob Brooks-Bilson | 5/17/07 6:32 PM



Copyright 1995-2008 Rob Brooks-Bilson. All rights reserved.
Aura skin for Raymond Camden's BlogCFC inspired by Joe Rinehart & Steven Erat. This blog is running version 5.5.1.