Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An example of how to implement looping in a ColdFusion custom tag (http://bit.ly/T5ikmR)
<!--- doLoop.cfm --->
<cf_loop iterations="10" index="i">
<cfoutput>[#i#]</cfoutput>Hello World<br />
</cf_loop>
<!--- loop.cfm --->
<cfif (THISTAG.ExecutionMode EQ "Start")>
<cfparam name="attributes.index" type="variablename">
<cfparam name="attributes.iterations" type="integer">
<cfset variables.index = 1>
<cfset caller[attributes.index] = variables.index>
<cfelse>
<cfset variables.index = variables.index + 1>
<cfif variables.index gt attributes.iterations>
<cfexit method="exittag">
<cfelse>
<cfset caller[attributes.index] = variables.index>
<cfexit method="loop">
</cfif>
</cfif>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment