I'm in the process of documenting all of CFScript. Well: how to effect all of CFML's functionality in CFScript, really.
Today I'm looking at how
<cfmodule>
is handled in CFScript. Railo and ColdFusion implement it differently (although Railo also implements ColdFusion's implementation for sideways compatibility).And I am puzzled with the way ColdFusion handles it.
First, some code.
Here's Railo's implementation:
module template="inc.cfm" attr1="val1" attr2="val2";
And in this case
inc.cfm
is this:
<cfdump var="#attributes#">
ColdFusion's implementation is this:
cfmodule(template="inc.cfm", attr1="val1", attr2="val2");
(whoever came up with the idea of prefixing everything with
cf
should be shot. Actually no. They should be put in a sack with a serpent, an ape, a cock and a cur. Then the sack should be thrown into the Tiber. Still: I digress).Anyhow, Railo does this:
Struct | |||
attr1 |
| ||
attr2 |
|
Fair enough. But ColdFusion does this:
struct | |
---|---|
ATTR1 | val1 |
ATTR2 | val2 |
struct | |
---|---|
ATTR1 | val1 |
ATTR2 | val2 |
Why? Well let's change
inc.cfm
to be this:<cfdump var="#thistag#">
And running now, we get this:
struct | |
---|---|
GeneratedContent | [empty string] |
executionMode | start |
hasendtag | YES |
struct | |
---|---|
GeneratedContent | [empty string] |
executionMode | end |
hasendtag | YES |
Now... my reaction to this is "oh you bloody idiots". Two things lead me to think this:
hasEndTag
isyes
? No. It definitely bloody isn't. Not only does it not have an end tag, it also doesn't have a start tag. Because it's not being run as a tag. FFS. It definitely does not have an end tag.- So we get a fictitious situation in which we get a "start" and "end" execution mode. There's no closing tag, so there's no reason to call the thing twice.
Am I missing something here? I suspect not, because Railo gets it right.
Note... one can have a block and have other code within it, using this syntax:
cfmodule(template="inc.cfm", attr1="val1", attr2="val2"){
writeOutput("within block");
}
And now both Railo and ColdFusion behave the same: the module is called both before and after the block. This makes sense.
ColdFusion's behaviour when there is no block does not make sense. Yes?
Now... where's my sack and the livestock?
--
Adam
PS: see "poena cullei".