Skip to content

Instantly share code, notes, and snippets.

@adamcameron
Created August 2, 2012 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamcameron/3234913 to your computer and use it in GitHub Desktop.
Save adamcameron/3234913 to your computer and use it in GitHub Desktop.
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