> Over at least the last year or so, I have seen more and 
> more CF code samples where people choose to use XML-type 
> syntax when coding CFML. My is: Why?
> 
> For those who might not know what I'm talking about, here's 
> a trivial example:
> 
> <cfset variables.myVar = "test" />
> <cfset variables.myOtherVar = "other test" />
> 
> On the one hand, since CFML looks so much like HTML's 
> tag-based syntax, I'm guessing people do it for consistency 
> to comply with XHTML standards. On the other hand, since 
> CFML is parsed before HTML is sent back to the browser,
> why even do this?

Consistency is good even when it's not necessary. There's no functional
reason for doing this, for most people who do, but if you are writing
XHTML-compliant HTML, you're less likely to screw that up if you get into
the habit of following XML syntax rules whenever possible, for example
within your server-side code.

Also, I imagine that you could potentially benefit from doing this in a more
concrete way. For example, you could write a code validation tool much more
easily if all your code followed general XML syntax, because you wouldn't
have to write a parser. I don't know anyone doing this yet, but it's bound
to happen sooner or later if it hasn't already.

> Further, in certain instances (i.e., custom tags), does
> the trailing slash cause the tag to be executed twice? For 
> example, would the following syntax cause myCT to be run 
> twice?
> 
> <cf_myCT />
> 
> Am I wrong about the duplicate execution of certain tags? Is 
> it only custom tags?

Yes, having the closing slash is functionally equivalent to having a closing
tag, and in either case the custom tag will run twice. The custom tag can
easily be written to only perform its task during the initial execution,
using the ThisTag.ExecutionMode variable, and in general, this is a good
thing to do if you're writing a custom tag that should only be executed
once.

As for other tags, I really don't know what happens, to be perfectly honest.
Most CFML tags are designed to have closing tags anyway.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to