The custom tag isn't rendering the content again, YOU are rendering
the content again.  If you create an empty custom tag and invoke it,
you'll get a single copy of the output.  If you then add emitting of
the generated content in the custom tag, you'll get two copies.  So
building up from the "nothing" case, you can see that you should
expect double output if you're doing outputting explicitly.

The EM tag in HTML is rather different, because it's being interpreted
as a formatting directive, not executed as code.  A better example
would be CFQUERY, where the generated content (the SQL statement) is
not emitted to the page output.  If you were to reimplement a
simplistic CFQUERY, it might look like this (using some "magic" helper
functions for brevity):

<cfif thisTag.executionMode EQ "start">
  <cfparam name="attributes.dsn" default="#application.dsn#" />
<cfelse>
  <cfset sql = thisTag.generatedContent />
  <cfset thisTag.generatedContent = "" />  <!--- we don't want the SQL
emitted --->
  <cfset result = runQueryOnDsn(attributes.dsn, sql) />
  <cfif structKeyExists(attributes, "name")>
    <cfset caller[attributes.name] = result />
  </cfif>
</cfif>

cheers,
barneyb

On Wed, Nov 4, 2009 at 2:06 PM, Mik Muller <[email protected]> wrote:
>
> Barney,
>
> Well, as I said, in this case the prinicple of least surprise would have 
> effused a behavior wherein the page calling the custom tag would not have 
> rendered the content, leaving that responsibility to the tag itself. In _my_ 
> mind, anyway. I mean, if the tag is supposed to receive the content, the 
> calling page really has no business rendering the content again.
>
> And not being able to stop it from being rendered again is a serious 
> drawback.  I mean, think of the lowly EM tag.  It takes the input and renders 
> the content in italics (or whatever). The browser doesn't then render the 
> content again UNitalicized, correct? It trusts the EM tag to take care of its 
> business. Isn't that the way a tag should work?
>
> I'll try your suggestion, below, but I've already gone the less elegant route 
> of using cfsavecontent around my content and pushing the resulting variable 
> as an attribute into the now-self-closing custom tag.
>
> Mik
>

-- 
Barney Boisvert
[email protected]
http://www.barneyb.co

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:328053
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to