Reputation: 821
I have a custom tag that displays the resume info to the browser of a user when a userid is passed to it. I want to return a variable with the html output to the calling page so that it can be used by a cfc. Can any one please comment on how to return the html in a variable? Is below the right way? And the calling page will look like
In custom tag <cfset caller[attributes.returnVar] = '#cv_content#'>
calling page <cf_cv_info user_id="295725" returnVar="foo">
thanks
Upvotes: 2
Views: 1705
Reputation: 7519
Inside your custom tag you can use the caller
scope, which is a reference to the page that called the custom tag.
DISCLAIMER This is not really 'best practice' as custom tags really should not reach outside of themselves - even though ColdFusion allows it. But this should work.
Inside your custom tag:
<cfset caller[ attributes.returnVar ] = 'moo' />
Inside your .cfm that calls the custom tag.
<cf_myCustomTagThatSetsSomeValue userid="12345" returnvar="someValue" >
<cfdump var="#someValue#" />
Edited based on Adam Cameron's and Joe Rinehart's comments
Upvotes: 5