Created
August 2, 2012 07:35
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- doLoop.cfm ---> | |
<cf_loop iterations="10" index="i"> | |
<cfoutput>[#i#]</cfoutput>Hello World<br /> | |
</cf_loop> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- 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